public RegionBase GetDomain(ImageBase image)//取得圖片的Region { RegionBase Regioninimage = new RegionBase(); HObject temp; HOperatorSet.GetDomain(image.GetImage, out temp); Regioninimage.CopyRegiontoThis(temp); temp.Dispose(); return Regioninimage; }
public ImageBase ChangeDomain(ImageBase image, RegionBase newregion)//取代原本的Region { ImageBase imagewithregion = new ImageBase(); HObject temp; HOperatorSet.ChangeDomain(image.GetImage, newregion.GetROI, out temp); imagewithregion.CopyImagetoThis(temp); temp.Dispose(); return imagewithregion; }
public ImageBase ReduceDomain(ImageBase image , RegionBase region)//基本上同Addchannels 將原有區域與Region取交集 { ImageBase imagewithregion = new ImageBase(); HObject temp; HOperatorSet.ReduceDomain(image.GetImage, region.GetROI, out temp); imagewithregion.CopyImagetoThis(temp); temp.Dispose(); return imagewithregion; }
public void AnisoShapeModel(RegionBase ROI, ImageBase modelImage) { HOperatorSet.ReduceDomain(modelImage.GetImage, ROI.GetROI, out ho_ImageROI); HOperatorSet.CreateAnisoShapeModel(ho_ImageROI, "auto", -0.39, 0.79, "auto",0.9, 1.1, "auto", 0.9, 1.1, "auto", "auto", "use_polarity", "auto", "auto",out hv_ModelID); HOperatorSet.GetShapeModelContours(out ho_ShapeModel, hv_ModelID, 1); HOperatorSet.FindAnisoShapeModel(modelImage.GetImage, hv_ModelID, 0, (new HTuple(360)).TupleRad(), 0.9, 1.1, 0.9, 1.1, 0.5, 1, 0.5, "least_squares", 0, 0.9, out hv_RowCheck,out hv_ColumnCheck, out hv_AngleCheck, out hv_ScaleR, out hv_ScaleC, out hv_Score); HTuple hv_I = null; for (hv_I = 0; (int)hv_I <= (int)((new HTuple(hv_Score.TupleLength())) - 1); hv_I = (int)hv_I + 1) { HOperatorSet.VectorAngleToRigid(0, 0, 0, hv_RowCheck.TupleSelect(hv_I),hv_ColumnCheck.TupleSelect(hv_I), hv_AngleCheck.TupleSelect(hv_I), out hv_MovementOfObject); HOperatorSet.AffineTransContourXld(ho_ShapeModel, out ho_ModelAtNewPosition,hv_MovementOfObject); } }
public void matchingNmeasure(MatchModel Model , Measure measure,ImageBase image_matchingNmeasure,RegionBase region_matchingNmeasure, RegionBase region_measure,HTuple window) { HOperatorSet.FindShapeModel(image_matchingNmeasure.GetImage, Model.get_ModelID, 0, (new HTuple(360)).TupleRad(), 0.6, 0, 0.5, "least_squares", 0, 0.7, out hv_RowCheck, out hv_ColumnCheck, out hv_AngleCheck, out hv_Score); HOperatorSet.GetShapeModelContours(out ho_ShapeModel, Model.get_ModelID, 1); HOperatorSet.VectorAngleToRigid(region_matchingNmeasure.GetRow, region_matchingNmeasure.GetColumn, 0, 0, 0, 0, out hv_MovementOfObject_O); //計算元件ROI原點轉換到影像座標原點的矩陣為何 HOperatorSet.AffineTransPoint2d(hv_MovementOfObject_O, region_measure.GetRow, region_measure.GetColumn, //依照上面的旋轉矩陣去計算測量的矩形轉換到原點做標後的中心 out hv_Row_Measure_O, out hv_Column_Measure_O); if ((int)(new HTuple((new HTuple(hv_Score.TupleLength())).TupleGreater(0.9))) != 0) { HOperatorSet.VectorAngleToRigid(0, 0, 0, hv_RowCheck, hv_ColumnCheck, hv_AngleCheck, out hv_MovementOfObject_contour); //產生旋轉矩陣(原點到匹配位置) HOperatorSet.AffineTransContourXld(Model.get_ShapeModel, out ho_ShapeModelAtNewPosition, hv_MovementOfObject_contour); //轉換Contour到匹配位置 HOperatorSet.AffineTransPoint2d(hv_MovementOfObject_contour, hv_Row_Measure_O, hv_Column_Measure_O, //使用上面得到的旋轉矩陣去轉換測量矩形的中心從原點到匹配位置 out hv_Row_Measure_Search, out hv_Column_Measure_Search); HOperatorSet.GenRectangle2(out ho_Measure_ROI_Search, hv_Row_Measure_Search, hv_Column_Measure_Search, //產生測量ROI區域 hv_AngleCheck + region_measure.GetPhi, region_measure.GetLength1Rectangle, region_measure.GetLength2Rectangle); HOperatorSet.GenRectangle2(out ho_line_show, hv_Row_Measure_Search, hv_Column_Measure_Search, //為了顯示而產生的Length2為零區域 hv_AngleCheck + region_measure.GetPhi, region_measure.GetLength1Rectangle, 0); HOperatorSet.GenMeasureRectangle2(hv_Row_Measure_Search, hv_Column_Measure_Search, hv_AngleCheck + //產生測量矩形 region_measure.GetPhi, region_measure.GetLength1Rectangle,region_measure.GetLength2Rectangle, image_matchingNmeasure.GetWidth, image_matchingNmeasure.GetHeight, "nearest_neighbor", out hv_MeasureHandle); HOperatorSet.MeasurePos(image_matchingNmeasure.GetImage, hv_MeasureHandle, 1, 25, "all", "all", out hv_RowEdge, out hv_ColumnEdge, //設定測量伐值 輸出測量錨點 out hv_Amplitude, out hv_Distance); HOperatorSet.GenCrossContourXld(out ho_Cross, hv_RowEdge, hv_ColumnEdge, 2 * region_measure.GetLength2Rectangle, //產生十字點 hv_AngleCheck); HOperatorSet.DispObj(image_matchingNmeasure.GetImage, window); HOperatorSet.DispObj(ho_ShapeModelAtNewPosition, window); HOperatorSet.SetColor(window, "blue"); HOperatorSet.DispObj(ho_Cross, window); HOperatorSet.SetColor(window, "red"); HOperatorSet.DispObj(ho_line_show, window); HOperatorSet.CloseMeasure(hv_MeasureHandle); } }
public void Measure_rectangle2(RegionBase ROI,ImageBase image,HTuple Sigma, HTuple threshold) { //Initialize local and output iconic variables HOperatorSet.GenEmptyObj(out ho_Cross); //清空ho_Cross HOperatorSet.GenMeasureRectangle2(ROI.GetRow, //產生測量矩形 ROI.GetColumn, ROI.GetPhi, ROI.GetLength1Rectangle, ROI.GetLength2Rectangle, image.GetWidth, image.GetHeight, "nearest_neighbor", out hv_MeasureHandle); HOperatorSet.MeasurePos(image.GetImage, hv_MeasureHandle, Sigma, threshold, //設定測量參數 並且輸出測量錨點 "all", "all", out hv_RowEdge, out hv_ColumnEdge, out hv_Amplitude, out hv_Distance); Measure_retangle2 = ROI.GetLength2Rectangle; Measure_Phi = ROI.GetPhi; HOperatorSet.CloseMeasure(hv_MeasureHandle); }
public void NCCModel(RegionBase ROI, ImageBase modelImage) { HOperatorSet.ReduceDomain(modelImage.GetImage, ROI.GetROI, out ho_ImageROI); HOperatorSet.CreateNccModel(ho_ImageROI, "auto", 0, 0, "auto", "use_polarity",out hv_ModelID); HOperatorSet.FindNccModel(modelImage.GetImage, hv_ModelID, 0, 0, 0.5, 1, 0.5, "true", 0,out hv_RowCheck, out hv_ColumnCheck, out hv_AngleCheck, out hv_Score); HTuple hv_I = null; for (hv_I = 0; (int)hv_I <= (int)((new HTuple(hv_Score.TupleLength())) - 1); hv_I = (int)hv_I + 1) { HOperatorSet.VectorAngleToRigid(0, 0, 0, hv_RowCheck.TupleSelect(hv_I),hv_ColumnCheck.TupleSelect(hv_I), hv_AngleCheck.TupleSelect(hv_I), out hv_MovementOfObject); HOperatorSet.AffineTransRegion(ROI.GetROI, out ho_RegionAffineTrans, hv_MovementOfObject, "nearest_neighbor"); } }
public void FastMatchMg(RegionBase ROI, ImageBase modelImage) { HOperatorSet.ReduceDomain(modelImage.GetImage, ROI.GetROI, out ho_ImageROI); HOperatorSet.CreateTemplate(ho_ImageROI, 255, 4, "sort", "original", out hv_ModelID); HOperatorSet.AdaptTemplate(modelImage.GetImage, hv_ModelID); HOperatorSet.FastMatchMg(modelImage.GetImage, out ho_Matches, hv_ModelID, 40, 3); HTuple hv_I = null; for (hv_I = 0; (int)hv_I <= (int)((new HTuple(hv_Score.TupleLength())) - 1); hv_I = (int)hv_I + 1) { HOperatorSet.VectorAngleToRigid(0, 0, 0, hv_RowCheck.TupleSelect(hv_I), hv_ColumnCheck.TupleSelect(hv_I), hv_AngleCheck.TupleSelect(hv_I), out hv_MovementOfObject); HOperatorSet.AffineTransRegion(ROI.GetROI, out ho_RegionAffineTrans, hv_MovementOfObject, "nearest_neighbor"); } }