Beispiel #1
0
        //filtering by double
        private static double[,] UnSharpHelperDouble(double[,] cPlane, string fType)
        {
            double[,] Result;
            if (fType == "unsharp")
            {
                Result = ImageFilter.Filter_double(cPlane, ImageFilter.Dx3FWindow(fType), PadType.replicate);
            }
            else
            {
                Result = cPlane.SubArrays(ImageFilter.Filter_double(cPlane, ImageFilter.Dx3FWindow(fType), PadType.replicate));
            }

            return(Result);
        }
Beispiel #2
0
        //filtering by int
        private static int[,] UnSharpHelperInt(int[,] cPlane, string fType)
        {
            int[,] Result;

            if (fType == "unsharp")
            {
                Result = (ImageFilter.Filter_double(cPlane, ImageFilter.Dx3FWindow(fType))).ArrayToUint8();
            }
            else
            {
                Result = cPlane.SubArrays(ImageFilter.Filter_int(cPlane, ImageFilter.Ix3FWindow(fType), PadType.replicate)).Uint8Range();
            }

            return(Result);
        }
Beispiel #3
0
        //
        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.");
            }
        }
Beispiel #4
0
 public static double[,] Filter_double(double[,] arr, string filterType)
 {
     return(Filter_double(arr, ImageFilter.Dx3FWindow(filterType), PadType.replicate));
 }