public static void Edge(Bitmap img, Edgevariant variant, EdgeMethod method, EdgeDirection direction) { LargeEdgeMethodVariant(img, variant, method, direction, 0); }
public static void Edge(Bitmap img, Edgevariant variant, EdgeMethod method, double threshold) { LargeEdgeMethodVariant(img, variant, method, EdgeDirection.def, threshold); }
//if absolutely black image - low the thresh value public static void Edge(Bitmap img, Edgevariant variant, double threshold) { LittleEdgeMethodVariant(img, variant, threshold); }
// private static void LittleEdgeMethodVariant(Bitmap img, Edgevariant variant, double threshold) { string imgExtension = GetImageInfo.Imginfo(Imageinfo.Extension); string imgName = GetImageInfo.Imginfo(Imageinfo.FileName); string defPath = GetImageInfo.MyPath("Segmentation\\Edge"); Bitmap image = new Bitmap(img.Width, img.Height, PixelFormat.Format24bppRgb); int[,] result = new int[img.Height, img.Width]; double Depth = System.Drawing.Image.GetPixelFormatSize(img.PixelFormat); string outName = String.Empty; double scale = 4; // for calculating the automatic threshold var imArray = MoreHelpers.BlackandWhiteProcessHelper(img); if ((imArray.GetLength(0) > 1 && imArray.GetLength(1) > 1) && (threshold >= 0 && threshold <= 1) && !(Checks.BinaryInput(img) && threshold == 0)) { if (variant == Edgevariant.var1) { result = EdgeHelperv1(scale, imArray, threshold, ImageFilter.Dx3FWindow("Sobel"), ImageFilter.Dx3FWindow("SobelT"), 8, EdgeDirection.both, imgName, imgExtension, EdgeTempName._EdgeDefaultVar1_temp); if (threshold == 0) { outName = defPath + imgName + "_EdgeDefV1" + imgExtension; } else { outName = defPath + imgName + "_EdgeDefV1" + "Th_" + threshold.ToString() + imgExtension; } } else { result = EdgeHelperv2(scale, imArray, threshold, ImageFilter.Dx3FWindow("Sobel"), ImageFilter.Dx3FWindow("SobelT"), 8, EdgeDirection.both); if (threshold == 0) { outName = defPath + imgName + "_EdgeDefV2" + imgExtension; } else { outName = defPath + imgName + "_EdgeDefV2" + "Th_" + threshold.ToString() + imgExtension; } } image = Helpers.SetPixels(image, result, result, result); if (Depth == 8) { PixelFormatWorks.Bpp24Gray2Gray8bppBitMap(image); } Helpers.SaveOptions(image, outName, imgExtension); } else { Console.WriteLine("Threshold must be in range [0..1]." + "\nOr may be Binary image at input and threshold = 0 - can`t process with such condition."); } }
//Find edges in intensity image //bad realization //segment little public static void Edge(Bitmap img, Edgevariant variant) { LittleEdgeMethodVariant(img, variant, 0); }