该案例包括模板匹配,固定和动态阈值,连通域,映射,筛选区域,形态学等等
ReadImage(ModelImage,‘1.jpg’)
GenRectangle1(hoRect, 171, 366, 205, 472);
AreaCenter(hoRect, Area, RowRef, ColumnRef)
ReduceDomain(ModelImage,hoRect, hoReduce)
CropDomain(hoReduce,hoCrop)
CreateNccModel(hoCrop,‘auto’, -0.39, 0.79, 1, ‘auto’,MtModelID)
GenRectangle1(MeasureROI1, 121, 144, 377, 529);
ReduceDomain(ModelImage,MeasureROI1, ImageReduced)
Threshold(ImageReduced,hoThrs,130,255)
Connection(hoThrs,hoConn)
SelectShape(hoConn,SelectedRegions,‘area’,‘and’, 25000, 99999)
ReadImage(hoImage,‘3.jpg’)
Rgb1ToGray(hoImage,hoImage)
FindNccModel(hoImage,MtModelID,-0.39, 0.79, 0.5,1, 0.5, 0,0,Row, Column, Angle, Score)
VectorAngleToRigid(RowRef, ColumnRef, 0, Row, Column, Angle, HomMat2D)
AffineTransRegion(SelectedRegions, RegionAffineTrans, HomMat2D, ‘nearest_neighbor’)
AffineTransImage(ModelImage, ImageAffinTrans, HomMat2D, ‘constant’, ‘false’)
ReduceDomain(ImageAffinTrans, RegionAffineTrans, ImageOri2);
ReduceDomain(hoImage, RegionAffineTrans, ImageThreshold);
DynThreshold(ImageOri2, ImageThreshold, hoDynRegion, 50, ‘light’);
ErosionCircle(RegionAffineTrans, hoErosion, 3);
Difference(hoErosion, hoDynRegion, RegionDifference);
Connection(RegionDifference, ConnectedRegions1);
SelectShape(ConnectedRegions1, SelectedRegions1, ‘area’, ‘and’, 15, 99999);
SetColor(3600,‘red’)
DispImage(hoImage,3600)
DispImage(SelectedRegions1,3600)
ClearNccModel(MtModelID)