public void PrewittAmp(ImageBase src_Image, ImageBase dst_Image) { HObject dst; HOperatorSet.PrewittAmp(src_Image.GetImage, out dst); dst_Image.CopyImagetoThis(dst); dst.Dispose(); }
public void MedianImage(ImageBase src_Image, ImageBase dst_Image) { HObject dst; HOperatorSet.MedianImage(src_Image.GetImage, out dst, "circle", 1, "mirrored"); dst_Image.CopyImagetoThis(dst); dst.Dispose(); }
public void LaplaceOfGauss(ImageBase src_Image, ImageBase dst_Image) { HObject dst; HOperatorSet.LaplaceOfGauss(src_Image.GetImage, out dst, 2); dst_Image.CopyImagetoThis(dst); dst.Dispose(); }
public void FillInterlace(ImageBase src_Image, ImageBase dst_Image) { HObject dst; HOperatorSet.FillInterlace(src_Image.GetImage, out dst, "odd"); dst_Image.CopyImagetoThis(dst); dst.Dispose(); }
public void DerivateGauss(ImageBase src_Image, ImageBase dst_Image) { HObject dst; HOperatorSet.DerivateGauss(src_Image.GetImage, out dst, 1, "x"); dst_Image.CopyImagetoThis(dst); dst.Dispose(); }
public void DiffOfGauss(ImageBase src_Image, ImageBase dst_Image) { HObject dst; HOperatorSet.DiffOfGauss(src_Image.GetImage, out dst, 3, 1.6); dst_Image.CopyImagetoThis(dst); dst.Dispose(); }
public void MeanSp(ImageBase src_Image, ImageBase dst_Image) { HObject dst; HOperatorSet.MeanSp(src_Image.GetImage, out dst, 3, 3, 1, 254); dst_Image.CopyImagetoThis(dst); dst.Dispose(); }
public void IsotropicDiffusion(ImageBase src_Image, ImageBase dst_Image) { HObject dst; HOperatorSet.IsotropicDiffusion(src_Image.GetImage, out dst, 1, 10); dst_Image.CopyImagetoThis(dst); dst.Dispose(); }
public void GrayErosionRect(ImageBase src_Image, ImageBase dst_Image) { HObject dst; HOperatorSet.GrayErosionRect(src_Image.GetImage, out dst, 20, 20); dst_Image.CopyImagetoThis(dst); dst.Dispose(); }
public void EliminateMinMax(ImageBase src_Image, ImageBase dst_Image) { HObject dst; HOperatorSet.EliminateMinMax(src_Image.GetImage, out dst, 3, 3, 1, 3); dst_Image.CopyImagetoThis(dst); dst.Dispose(); }
/*Emphasize MaskWidth (input_control) extent.x → (integer) Width of low pass MaskBase. Default value: 7 Suggested values: 3, 5, 7, 9, 11, 15, 21, 25, 31, 39 Typical range of values: 3 ≤ MaskWidth ≤ 201 Minimum increment: 2 Recommended increment: 2 MaskHeight (input_control) extent.y → (integer) Height of the low pass MaskBase. Default value: 7 Suggested values: 3, 5, 7, 9, 11, 15, 21, 25, 31, 39 Typical range of values: 3 ≤ MaskHeight ≤ 201 Minimum increment: 2 Recommended increment: 2 Factor (input_control) real → (real) Intensity of contrast emphasis. Default value: 1.0 Suggested values: 0.3, 0.5, 0.7, 1.0, 1.4, 1.8, 2.0 Typical range of values: 0.0 ≤ Factor ≤ 20.0 (sqrt) Minimum increment: 0.01 Recommended increment: 0.2 Restriction: (0 < Factor) && (Factor < 20) */ public void Emphasize(ImageBase src_Image, ImageBase dst_Image,MaskBase maskEmphasize, HTuple factor) { HObject dst; HOperatorSet.Emphasize(src_Image.GetImage, out dst, maskEmphasize.W, maskEmphasize.H, factor); dst_Image.CopyImagetoThis(dst); dst.Dispose(); }
/*CoherenceEnhancingDiff Sigma (input_control) real → (real) Smoothing for derivative operator. Default value: 0.5 Suggested values: 0.0, 0.1, 0.5, 1.0 Restriction: Sigma >= 0 Rho (input_control) real → (real) Smoothing for diffusion coefficients. Default value: 3.0 Suggested values: 0.0, 1.0, 3.0, 5.0, 10.0, 30.0 Restriction: Rho >= 0 Theta (input_control) real → (real) Time step. Default value: 0.5 Suggested values: 0.1, 0.2, 0.3, 0.4, 0.5 Restriction: (0 < Theta) <= 0.5 Iterations (input_control) integer → (integer) Number of iterations. Default value: 10 Suggested values: 1, 5, 10, 20, 50, 100, 500 Restriction: Iterations >= 1 */ public void CoherenceEnhancingDiff(ImageBase src_Image, ImageBase dst_Image, HTuple sigma, HTuple rho, HTuple theta, HTuple iterations) { HObject dst; HOperatorSet.CoherenceEnhancingDiff(src_Image.GetImage, out dst, sigma, rho, theta, iterations); dst_Image.CopyImagetoThis(dst); dst.Dispose(); }
public void CoherenceEnhancingDiff(ImageBase src_Image, ImageBase dst_Image) { HObject dst; HOperatorSet.CoherenceEnhancingDiff(src_Image.GetImage, out dst, 0.5, 3, 0.5, 10); dst_Image.CopyImagetoThis(dst); dst.Dispose(); }
public void ZoomImageFactor(ImageBase srcImage, ImageBase dstImage, HTuple scaleWidth, HTuple scaleHeight) { HObject tempImage = null; HOperatorSet.ZoomImageFactor(srcImage.GetImage, out tempImage, scaleWidth, scaleHeight, "constant"); dstImage.CopyImagetoThis(tempImage); tempImage.Dispose(); }
public void GaussFilter(ImageBase src_Image, ImageBase dst_Image) { HObject dst; HOperatorSet.GaussFilter(src_Image.GetImage, out dst, 5); dst_Image.CopyImagetoThis(dst); dst.Dispose(); }
public void Laplace(ImageBase src_Image, ImageBase dst_Image) { HObject dst; HOperatorSet.Laplace(src_Image.GetImage, out dst, "absolute", 3, "n_4"); dst_Image.CopyImagetoThis(dst); dst.Dispose(); }
private void sT_LoadImage_Click(object sender, EventArgs e) { sT_Window.Window.Focus(); sT_Window.Window_Image = sT_LoadImage.getloadimage; MainImage = sT_LoadImage.getloadimage; sT_Window.Window_Image.ShowImage_autosize(sT_Window.Window.HalconWindow); }
public void EdgesImage(ImageBase src_Image, ImageBase dst_Image) { HObject dst; HObject dst1; HOperatorSet.EdgesImage(src_Image.GetImage, out dst, out dst1, "canny", 1, "nms",20, 40); dst_Image.CopyImagetoThis(dst); dst.Dispose(); }
public void AffineTransImage(ImageBase srcImage, ImageBase dstImage, HTuple row, HTuple col , HTuple ang) { HTuple hv_HomMat2D=null; HObject tempImage = null; HOperatorSet.VectorAngleToRigid(srcImage.GetWidth / 2, srcImage.GetHeight / 2, 0 ,row ,col, ang , out hv_HomMat2D); HOperatorSet.AffineTransImage(srcImage.GetImage, out tempImage, hv_HomMat2D,"constant", "'false"); dstImage.CopyImagetoThis(tempImage); tempImage.Dispose(); }
// Main procedure public void Metrology_line(HTuple Windows,ImageBase IMG) { // Local iconic variables HObject ho_Image, ho_MeasureConts, ho_Cross; HObject ho_line; // Local control variables HTuple hv_WindowHandle = new HTuple(), hv_Width = null; HTuple hv_Height = null, hv_MetrologyHandle = null, hv_Row1 = null; HTuple hv_Column1 = null, hv_Row2 = null, hv_Column2 = null; HTuple hv_Index1 = null, hv_Par = null, hv_Rtmp = null; HTuple hv_Ctmp = null; // Initialize local and output iconic variables HOperatorSet.GenEmptyObj(out ho_Image); HOperatorSet.GenEmptyObj(out ho_MeasureConts); HOperatorSet.GenEmptyObj(out ho_Cross); HOperatorSet.GenEmptyObj(out ho_line); ho_Image.Dispose(); ho_Image = IMG.GetImage.Clone(); //dev_close_window(...); //dev_open_window(...); HOperatorSet.DispObj(ho_Image, Windows); HOperatorSet.GetImageSize(ho_Image, out hv_Width, out hv_Height); HOperatorSet.CreateMetrologyModel(out hv_MetrologyHandle); HOperatorSet.SetMetrologyModelImageSize(hv_MetrologyHandle, hv_Width, hv_Height); HOperatorSet.DrawLine(Windows, out hv_Row1, out hv_Column1, out hv_Row2, out hv_Column2); HOperatorSet.AddMetrologyObjectLineMeasure(hv_MetrologyHandle, hv_Row1, hv_Column1, hv_Row2, hv_Column2, 20, 5, 1, 10, "measure_transition", "all", out hv_Index1); HOperatorSet.ApplyMetrologyModel(ho_Image, hv_MetrologyHandle); HOperatorSet.GetMetrologyObjectResult(hv_MetrologyHandle, "all", "all", "result_type", "all_param", out hv_Par); ho_MeasureConts.Dispose(); HOperatorSet.GetMetrologyObjectMeasures(out ho_MeasureConts, hv_MetrologyHandle, "all", "all", out hv_Rtmp, out hv_Ctmp); ho_Cross.Dispose(); HOperatorSet.GenCrossContourXld(out ho_Cross, hv_Rtmp, hv_Ctmp, 6, (new HTuple(45)).TupleRad() ); HOperatorSet.DispObj(ho_Image, Windows); HOperatorSet.SetColor(Windows, "blue"); HOperatorSet.DispObj(ho_Cross, Windows); HOperatorSet.SetColor(Windows, "red"); ho_line.Dispose(); HOperatorSet.GenRegionLine(out ho_line, hv_Par.TupleSelect(0), hv_Par.TupleSelect( 1), hv_Par.TupleSelect(2), hv_Par.TupleSelect(3)); HOperatorSet.DispObj(ho_line, Windows); ho_Image.Dispose(); ho_MeasureConts.Dispose(); ho_Cross.Dispose(); ho_line.Dispose(); }
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 void KirschDir(ImageBase src_Image, ImageBase dst_Image) { HObject dst; HObject dst1; HOperatorSet.KirschDir(src_Image.GetImage, out dst, out dst1); dst_Image.CopyImagetoThis(dst); dst.Dispose(); }
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 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 MedianRect(ImageBase src_Image, ImageBase dst_Image) { HObject dst; HOperatorSet.MedianRect(src_Image.GetImage, out dst, 15, 15); dst_Image.CopyImagetoThis(dst); dst.Dispose(); }
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"); } }