Exemplo n.º 1
0
        public static void Mirror(Bitmap img, MirrorOption side)
        {
            string imgExtension = GetImageInfo.Imginfo(Imageinfo.Extension);
            string imgName      = GetImageInfo.Imginfo(Imageinfo.FileName);
            string defPath      = GetImageInfo.MyPath("Rand");

            Bitmap image = new Bitmap(img.Width, img.Height, PixelFormat.Format24bppRgb);

            image = MirrorHelper(img, side);

            int index = 0;

            foreach (var n in Enum.GetValues(typeof(MirrorOption)).Cast <MirrorOption>())
            {
                if (n == side)
                {
                    index = (int)n; break;
                }
                ;
            }

            string outName = defPath + imgName + MirrorVariant.ElementAt(index) + imgExtension;

            Helpers.SaveOptions(image, outName, imgExtension);
        }
Exemplo n.º 2
0
        public static void RGBtoAnothercolorSpacetoFile(Bitmap img, RGBtoAnotherColorSpace colorSpace)
        {
            string imgName = GetImageInfo.Imginfo(Imageinfo.FileName);
            List <ArraysListInt> ColorList = Helpers.GetPixels(img);

            RGBtoAnothercolorSpacetoFile(ColorList, colorSpace, imgName);
        }
Exemplo n.º 3
0
        private static void ShapkaProcess(Bitmap img, double[,] tform, int r, int c, string fileName, bool ext)
        {
            string ImgExtension = GetImageInfo.Imginfo(Imageinfo.Extension);
            string imgName      = GetImageInfo.Imginfo(Imageinfo.FileName);
            string defPath      = GetImageInfo.MyPath("Affine");

            Bitmap image = new Bitmap(c, r, PixelFormat.Format24bppRgb);
            double Depth = System.Drawing.Image.GetPixelFormatSize(img.PixelFormat);

            List <ArraysListInt> ColorList = Helpers.GetPixels(img);

            int[,] resultR = new int[r, c];
            int[,] resultG = new int[r, c];
            int[,] resultB = new int[r, c];

            if (Depth == 1 || Depth == 8)
            {
                if (ext)
                {
                    resultR = ExtenstionCount(ColorList[0].Color, tform, r, c);
                }
                else
                {
                    resultR = AffineCount(ColorList[0].Color, tform, r, c);
                }

                resultG = resultR; resultB = resultR;
            }
            else
            {
                if (ext)
                {
                    resultR = ExtenstionCount(ColorList[0].Color, tform, r, c);
                    resultG = ExtenstionCount(ColorList[1].Color, tform, r, c);
                    resultB = ExtenstionCount(ColorList[2].Color, tform, r, c);
                }
                else
                {
                    resultR = AffineCount(ColorList[0].Color, tform, r, c);
                    resultG = AffineCount(ColorList[1].Color, tform, r, c);
                    resultB = AffineCount(ColorList[2].Color, tform, r, c);
                }
            }

            image = Helpers.SetPixels(image, resultR, resultG, resultB);

            if (Depth == 8)
            {
                image = PixelFormatWorks.Bpp24Gray2Gray8bppBitMap(image);
            }
            if (Depth == 1)
            {
                image = PixelFormatWorks.ImageTo1BppBitmap(image, 0.5);
            }

            string outName = defPath + imgName + fileName + ImgExtension;

            Helpers.SaveOptions(image, outName, ImgExtension);
        }
Exemplo n.º 4
0
        //save image in othe format, your cap
        public static void SaveImageInOtherFormat(Bitmap image, SupportFormats newFormat)
        {
            string imgName = GetImageInfo.Imginfo(Imageinfo.FileName);
            string defPath = GetImageInfo.MyPath("Rand");

            string outName = defPath + imgName + newFormat.ToString();

            Helpers.SaveOptions(image, outName, newFormat.ToString().ToLower());
        }
Exemplo n.º 5
0
        //Some morph operations with binary image, or represented as binary
        public static void Bwmorph(Bitmap img, BwmorphOpearion operation, int repeat, OutType type)
        {
            string imgExtension = GetImageInfo.Imginfo(Imageinfo.Extension);
            string imgName      = GetImageInfo.Imginfo(Imageinfo.FileName);
            string defPath      = GetImageInfo.MyPath("Morph\\BWMorph");

            var    result  = BwmorphHelper(img, operation, repeat);
            string outName = defPath + imgName + "_" + operation.ToString() + "_repeat_" + repeat + imgExtension;

            MoreHelpers.WriteImageToFile(result, result, result, outName, type);
        }
Exemplo n.º 6
0
        private static void HitMissShapkaProcess(Bitmap img, int[,] FirstStructureElement, int[,] SecondStructureElement, OutType type)
        {
            string imgExtension = GetImageInfo.Imginfo(Imageinfo.Extension);
            string imgName      = GetImageInfo.Imginfo(Imageinfo.FileName);
            string defPath      = GetImageInfo.MyPath("Morph\\BWHitMiss");

            int[,] result = BWHitMissProcess(img, FirstStructureElement, SecondStructureElement);
            string outName = defPath + imgName + "_BWHitMiss" + imgExtension;

            MoreHelpers.WriteImageToFile(result, result, result, outName, type);
        }
Exemplo n.º 7
0
        private static void SaltPepperFilterHelper(Bitmap img, int m, int n, double filterOrder, SaltPepperfilterType spfiltType, bool unsharp)
        {
            string imgExtension = GetImageInfo.Imginfo(Imageinfo.Extension);
            string imgName      = GetImageInfo.Imginfo(Imageinfo.FileName);
            string defPath      = GetImageInfo.MyPath("SaltPepper");

            Bitmap image = new Bitmap(img.Width, img.Height, PixelFormat.Format24bppRgb);

            string outName = defPath + imgName + FilterVariants.ElementAt((int)spfiltType) + imgExtension;

            Helpers.SaveOptions(image, outName, imgExtension);
        }
Exemplo n.º 8
0
        //find lines
        public static void Lines(Bitmap img, LineDirection lineDirection)
        {
            string imgName = GetImageInfo.Imginfo(Imageinfo.FileName);
            string defPath = GetImageInfo.MyPath("Segmentation\\Lines");

            Bitmap image = new Bitmap(img.Width, img.Height, PixelFormat.Format24bppRgb);

            int[,] lineRes = new int[img.Height, img.Width];
            string outName = String.Empty;

            var imArray = MoreHelpers.BlackandWhiteProcessHelper(img);

            if (imArray.GetLength(0) > 1 && imArray.GetLength(1) > 1)
            {
                //choose filter and use it
                switch (lineDirection)
                {
                case LineDirection.horizontal:
                    double[,] horisontalFilter = { { -1, -1, -1 }, { 2, 2, 2 }, { -1, -1, -1 } };

                    lineRes = FindLineHelper(imArray, horisontalFilter);
                    outName = defPath + imgName + "_HorisontalLine.png";
                    break;

                case LineDirection.vertical:
                    double[,] verticalFilter = { { -1, 2, -1 }, { -1, 2, -1 }, { -1, 2, -1 } };

                    lineRes = FindLineHelper(imArray, verticalFilter);
                    outName = defPath + imgName + "_VerticalLine.png";
                    break;

                case LineDirection.plus45:
                    double[,] plus45Filter = { { -1, -1, 2 }, { -1, 2, -1 }, { 2, -1, -1 } };

                    lineRes = FindLineHelper(imArray, plus45Filter);
                    outName = defPath + imgName + "_Plus45Line.png";
                    break;

                case LineDirection.minus45:
                    double[,] minus45Filter = { { 2, -1, -1 }, { -1, 2, -1 }, { -1, -1, 2 } };

                    lineRes = FindLineHelper(imArray, minus45Filter);
                    outName = defPath + imgName + "_Minus45Line.png";
                    break;
                }

                image = Helpers.SetPixels(image, lineRes, lineRes, lineRes);
                image = PixelFormatWorks.Bpp24Gray2Gray8bppBitMap(image);

                Helpers.SaveOptions(image, outName, ".png");
            }
        }
Exemplo n.º 9
0
        //convert 24bpp RGB image into 8bpp gray
        public static void RGB2Gray8bpp(Bitmap img)
        {
            string imgName = GetImageInfo.Imginfo(Imageinfo.FileName);
            string defPath = GetImageInfo.MyPath("Rand");

            Bitmap image = new Bitmap(img.Width, img.Height, PixelFormat.Format8bppIndexed);

            image = RGB2Gray8bppConveter(img);

            string outName = defPath + imgName + "_rgbToGray8bppIndexed.png";

            Helpers.SaveOptions(image, outName, ".png");
        }
Exemplo n.º 10
0
        public static void ImageTo1Bpp(Bitmap img, double level)
        {
            string imgName = GetImageInfo.Imginfo(Imageinfo.FileName);
            string defPath = GetImageInfo.MyPath("Rand");

            Bitmap image = new Bitmap(img.Width, img.Height, PixelFormat.Format1bppIndexed);

            image = ImageTo1BppConverter(img, level);

            string outName = defPath + imgName + "_1BppImageLvl_" + level.ToString() + ".png";

            Helpers.SaveOptions(image, outName, ".png");
        }
Exemplo n.º 11
0
        //image smoothing by entered size for average filter and save to file
        public static void Smooth(Bitmap img, int m, int n, SmoothInColorSpace cSpace)
        {
            string imgExtension = GetImageInfo.Imginfo(Imageinfo.Extension);
            string imgName      = GetImageInfo.Imginfo(Imageinfo.FileName);
            string defPath      = GetImageInfo.MyPath("Sharp\\Smooth");

            Bitmap image = new Bitmap(img.Width, img.Height, PixelFormat.Format24bppRgb);

            image = SmoothHelper(img, m, n, cSpace);

            string outName = defPath + imgName + SmoothVariants.ElementAt((int)cSpace) + imgExtension;

            Helpers.SaveOptions(image, outName, imgExtension);
        }
Exemplo n.º 12
0
        //L component CIE1976 experiment to file how it`s look like
        public static void FakeCIE1976LtoFile(Bitmap img)
        {
            string imgName = GetImageInfo.Imginfo(Imageinfo.FileName);
            string defPath = GetImageInfo.MyPath("ColorSpace\\ColorSpacePlane");

            int[,] fake = ColorSpace.FakeCIE1976L(img).ArrayToUint8();

            img = Helpers.SetPixels(img, fake, fake, fake);
            img = PixelFormatWorks.Bpp24Gray2Gray8bppBitMap(img);

            string outName = defPath + imgName + "_FakeCIE1976L.png";

            Helpers.SaveOptions(img, outName, ".png");
        }
Exemplo n.º 13
0
        //Invert binaty image or colored by some plane

        public static void InverseBinary(Bitmap img, OutType type)
        {
            string imgExtension = GetImageInfo.Imginfo(Imageinfo.Extension);
            string imgName      = GetImageInfo.Imginfo(Imageinfo.FileName);
            string defPath      = GetImageInfo.MyPath("Rand");

            Bitmap image = new Bitmap(img.Width, img.Height, PixelFormat.Format24bppRgb);

            image = InverseBinaryHelper(img, type);

            string outName = defPath + imgName + "_InverseBinary" + imgExtension;

            Helpers.SaveOptions(image, outName, imgExtension);
        }
Exemplo n.º 14
0
        //make negative of image

        public static void MakeNegativeAndBack(Bitmap img)
        {
            string imgExtension = GetImageInfo.Imginfo(Imageinfo.Extension);
            string imgName      = GetImageInfo.Imginfo(Imageinfo.FileName);
            string defPath      = GetImageInfo.MyPath("Rand");

            Bitmap image = new Bitmap(img.Width, img.Height, PixelFormat.Format24bppRgb);

            image = MakeNegativeAndBackHelper(img);

            string outName = defPath + imgName + "_NegativeOrRestored" + imgExtension;

            Helpers.SaveOptions(image, outName, imgExtension);
        }
Exemplo n.º 15
0
        //crom image by entered values form sides

        public static void CropImage(Bitmap img, int cutLeft, int cutRight, int cutTop, int cutBottom)
        {
            string imgExtension = GetImageInfo.Imginfo(Imageinfo.Extension);
            string imgName      = GetImageInfo.Imginfo(Imageinfo.FileName);
            string defPath      = GetImageInfo.MyPath("Rand");

            Bitmap image = new Bitmap(img.Width, img.Height, PixelFormat.Format24bppRgb);

            image = CropImageHelper(img, cutLeft, cutRight, cutTop, cutBottom);

            string outName = defPath + imgName + "_cropped" + imgExtension;

            Helpers.SaveOptions(image, outName, imgExtension);
        }
Exemplo n.º 16
0
        public static void ApplyFilter(Bitmap img, double[,] filter, string filterData, FSpecialColorSpace cSpace, FSpecialFilterType filterType)
        {
            string imgExtension = GetImageInfo.Imginfo(Imageinfo.Extension);
            string imgName      = GetImageInfo.Imginfo(Imageinfo.FileName);
            string defPath      = GetImageInfo.MyPath("FSpecial");

            Bitmap image = new Bitmap(img.Width, img.Height, PixelFormat.Format24bppRgb);

            image = FSpecialHelper(img, filter, cSpace, filterType);

            string outName = defPath + imgName + SharpVariants.ElementAt((int)cSpace) + filterType.ToString() + filterData + imgExtension;

            Helpers.SaveOptions(image, outName, imgExtension);
        }
Exemplo n.º 17
0
        public static void HighContrastColored(Bitmap img, ContrastFilter filter, HighContastRGB cPlane)
        {
            string imgExtension = GetImageInfo.Imginfo(Imageinfo.Extension);
            string imgName      = GetImageInfo.Imginfo(Imageinfo.FileName);
            string defPath      = GetImageInfo.MyPath("Contrast\\HighContrastFilter");

            Bitmap image = new Bitmap(img.Width, img.Height, PixelFormat.Format24bppRgb);

            image = HighContrastProcess(img, filter, cPlane);

            string outName = defPath + imgName + "_" + filter.ToString() + imgExtension;

            Helpers.SaveOptions(image, outName, imgExtension);
        }
Exemplo n.º 18
0
        //Sharpen the image and save to file
        public static void Sharp(Bitmap img, UnSharpInColorSpace cSpace, SharpFilterType filterType)
        {
            string imgExtension = GetImageInfo.Imginfo(Imageinfo.Extension);
            string imgName      = GetImageInfo.Imginfo(Imageinfo.FileName);
            string defPath      = GetImageInfo.MyPath("Sharp\\unSharp");

            Bitmap image = new Bitmap(img.Width, img.Height, PixelFormat.Format24bppRgb);

            image = SharpHelper(img, cSpace, filterType);

            string outName = defPath + imgName + SharpVariants.ElementAt((int)cSpace) + filterType.ToString() + imgExtension;

            Helpers.SaveOptions(image, outName, imgExtension);
        }
Exemplo n.º 19
0
        //creater CheckerBoard on RGB image alternating gray and color cells

        //n - pixels per cell
        public static void WildBoard(Bitmap img, int n, WildBoardVariant variant)
        {
            string imgExtension = GetImageInfo.Imginfo(Imageinfo.Extension);
            string imgName      = GetImageInfo.Imginfo(Imageinfo.FileName);
            string defPath      = GetImageInfo.MyPath("Rand");

            Bitmap image = new Bitmap(img.Width, img.Height, PixelFormat.Format24bppRgb);

            image = WildBoardHelepr(img, n, variant);

            string outName = defPath + imgName + "_CheckerBoard" + imgExtension;

            Helpers.SaveOptions(image, outName, imgExtension);
        }
Exemplo n.º 20
0
        //Ahtung! for HSV & Lab lost in accuracy, coz convert double->int->double
        //Equalize histogram for image by using separate color plane and save to file
        public static void Equalize(Bitmap img, HisteqColorSpace cSpace)
        {
            string imgExtension = GetImageInfo.Imginfo(Imageinfo.Extension);
            string imgName      = GetImageInfo.Imginfo(Imageinfo.FileName);
            string defPath      = GetImageInfo.MyPath("Sharp\\Histeq");

            Bitmap image = new Bitmap(img.Width, img.Height, PixelFormat.Format24bppRgb);

            image = EqualizeHelper(img, cSpace);

            string outName = defPath + imgName + HisteqVariants.ElementAt((int)cSpace) + imgExtension;

            Helpers.SaveOptions(image, outName, imgExtension);
        }
Exemplo n.º 21
0
        public static void InvertColorPlane(Bitmap img, InveseVariant variant)
        {
            string ImgExtension = GetImageInfo.Imginfo(Imageinfo.Extension);
            string imgName      = GetImageInfo.Imginfo(Imageinfo.FileName);
            string defPath      = GetImageInfo.MyPath("Rand");

            Bitmap image = new Bitmap(img.Width, img.Height, PixelFormat.Format24bppRgb);

            image = InvertColorPlaneHelper(img, variant);

            string outName = defPath + imgName + "_" + variant.ToString() + ImgExtension;

            Helpers.SaveOptions(image, outName, ImgExtension);
        }
Exemplo n.º 22
0
        private static void ThresholdShapkaProcess(Bitmap img, Bitmap adaptOrig, string method, bool adaptive)
        {
            string imgExtension = GetImageInfo.Imginfo(Imageinfo.Extension);
            string imgName      = GetImageInfo.Imginfo(Imageinfo.FileName);
            string defPath      = GetImageInfo.MyPath("Segmentation\\Graythresh");

            Bitmap image = new Bitmap(img.Width, img.Height, PixelFormat.Format24bppRgb);

            image = GraythreshProcess(img, adaptOrig, adaptive);

            string outName = defPath + imgName + method + imgExtension;

            Helpers.SaveOptions(image, outName, imgExtension);
        }
Exemplo n.º 23
0
        //save into file contour after process
        public static void FindContour(Bitmap img, CountourVariant variant)
        {
            string imgExtension = GetImageInfo.Imginfo(Imageinfo.Extension);
            string imgName      = GetImageInfo.Imginfo(Imageinfo.FileName);
            string defPath      = GetImageInfo.MyPath("Contour");

            Bitmap image = new Bitmap(img.Width, img.Height, PixelFormat.Format24bppRgb);

            image = ContourHelper(img, variant);

            string outName = defPath + imgName + variant.GetEnumDescription() + imgExtension;

            Helpers.SaveOptions(image, outName, imgExtension);
        }
Exemplo n.º 24
0
        //convert 8bpp image into 24bpp BW
        public static void Bpp8fastTo24bppGray(Bitmap img)
        {
            string imgExtension = GetImageInfo.Imginfo(Imageinfo.Extension);
            string imgName      = GetImageInfo.Imginfo(Imageinfo.FileName);
            string defPath      = GetImageInfo.MyPath("Rand");

            Bitmap image = new Bitmap(img.Width, img.Height, PixelFormat.Format24bppRgb);

            image = Bpp8fastTo24bppGrayHelper(img);

            string outName = defPath + imgName + "_8bppto24bpp" + imgExtension;

            Helpers.SaveOptions(image, outName, imgExtension);
        }
Exemplo n.º 25
0
        private static void SpeckleShapkaProcess(Bitmap img, double variance)
        {
            string imgExtension = GetImageInfo.Imginfo(Imageinfo.Extension);
            string imgName      = GetImageInfo.Imginfo(Imageinfo.FileName);
            string defPath      = GetImageInfo.MyPath("Noise");

            Bitmap image = new Bitmap(img.Width, img.Height, PixelFormat.Format24bppRgb);
            double Depth = System.Drawing.Image.GetPixelFormatSize(img.PixelFormat);

            List <ArraysListInt> ColorList = Helpers.GetPixels(img);

            int[,] resultR = new int[img.Height, img.Width];
            int[,] resultG = new int[img.Height, img.Width];
            int[,] resultB = new int[img.Height, img.Width];

            if (variance > 0)
            {
                double[,] noise = Helpers.RandArray(img.Height, img.Width);

                if (Depth != 1 && Depth != 8)
                {
                    resultR = Speckle(ColorList[0].Color, variance, noise);
                    resultG = Speckle(ColorList[1].Color, variance, noise);
                    resultB = Speckle(ColorList[2].Color, variance, noise);
                }
                else
                {
                    Depth   = 8;
                    resultR = Speckle(ColorList[0].Color, variance, noise);
                    resultG = resultR; resultB = resultR;
                }

                image = Helpers.SetPixels(image, resultR, resultG, resultB);

                if (Depth == 8)
                {
                    image = PixelFormatWorks.Bpp24Gray2Gray8bppBitMap(image);
                }
            }
            else
            {
                Console.WriteLine("Variance must be greater 0. Method NoiseTry.SpeckleNoise(). Return black rectangle.");
            }

            string outName = defPath + imgName + "_speckleNoise_variance_" + variance + imgExtension;

            Helpers.SaveOptions(image, outName, imgExtension);
        }
Exemplo n.º 26
0
        //form output name and save contrast process image to file
        private static void ContrastRGBHelper(Bitmap img, double Rc_low_in, double Rc_high_in, double Gc_low_in, double Gc_high_in, double Bc_low_in, double Bc_high_in,
                                              double Rc_low_out, double Rc_high_out, double Gc_low_out, double Gc_high_out, double Bc_low_out, double Bc_high_out, double gamma)
        {
            string imgExtension = GetImageInfo.Imginfo(Imageinfo.Extension);
            string imgName      = GetImageInfo.Imginfo(Imageinfo.FileName);
            string defPath      = GetImageInfo.MyPath("Contrast\\RGB");

            Bitmap image   = new Bitmap(img.Width, img.Height, PixelFormat.Format24bppRgb);
            string outName = string.Empty;

            image = ContrastRGBProcess(img, Rc_low_in, Rc_high_in, Gc_low_in, Gc_high_in, Bc_low_in, Bc_high_in,
                                       Rc_low_out, Rc_high_out, Gc_low_out, Gc_high_out, Bc_low_out, Bc_high_out, gamma);

            if (Rc_low_out == 0 && Rc_high_out == 0 && Gc_low_out == 0 && Gc_high_out == 0 &&
                Bc_low_out == 0 && Bc_high_out == 0)
            {
                if (gamma != 1)
                {
                    outName = defPath + imgName + "_ContrastRGBIn[" + Rc_low_in + "," + Gc_low_in + "," + Bc_low_in
                              + ";" + Rc_high_in + "," + Gc_high_in + "," + Bc_high_in + "]Gam_" + gamma + imgExtension;
                }

                else
                {
                    outName = defPath + imgName + "_ContrastRGBIn[" + Rc_low_in + "," + Gc_low_in + "," + Bc_low_in
                              + ";" + Rc_high_in + "," + Gc_high_in + "," + Bc_high_in + "]" + imgExtension;
                }
            }
            else
            {
                if (gamma != 1)
                {
                    outName = defPath + imgName + "_ContrastRGBIn[" + Rc_low_in + "," + Gc_low_in + "," + Bc_low_in
                              + ";" + Rc_high_in + "," + Gc_high_in + "," + Bc_high_in + "]Out[";
                    outName = outName + Rc_low_out + "," + Gc_low_out + "," + Bc_low_out
                              + ";" + Rc_high_out + "," + Gc_high_out + "," + Bc_high_out + "]Gam_" + gamma + imgExtension;
                }
                else
                {
                    outName = defPath + imgName + "_ContrastRGBIn[" + Rc_low_in + "," + Gc_low_in + "," + Bc_low_in
                              + ";" + Rc_high_in + "," + Gc_high_in + "," + Bc_high_in + "]Out[";
                    outName = outName + Rc_low_out + "," + Gc_low_out + "," + Bc_low_out
                              + ";" + Rc_high_out + "," + Gc_high_out + "," + Bc_high_out + "]" + imgExtension;
                }
            }

            Helpers.SaveOptions(image, outName, imgExtension);
        }
Exemplo n.º 27
0
        //convert RGB image to 24bpp BW and save to file
        public static void RGBtoBlackWhite24bpp(Bitmap img)
        {
            string imgExtension = GetImageInfo.Imginfo(Imageinfo.Extension);
            string imgName      = GetImageInfo.Imginfo(Imageinfo.FileName);
            string defPath      = GetImageInfo.MyPath("Rand");

            Bitmap image = new Bitmap(img.Width, img.Height, PixelFormat.Format24bppRgb);

            if (Checks.RGBinput(img))
            {
                var gray = Helpers.RGBToGrayArray(img);
                image = Helpers.SetPixels(image, gray, gray, gray);

                string outName = defPath + "_rgbToGray24bpp" + imgExtension;
                Helpers.SaveOptions(img, outName, imgExtension);
            }
        }
Exemplo n.º 28
0
        //constOne - c for gamma\log (multCoeff); m for stretch
        //constTwo - e for stretch; gamma for gammaCorr :o
        private static void BrightTransformationShapka(Bitmap img, string operation, BrightConvPlane plane, double constOne, double constTwo)
        {
            string imgExtension = GetImageInfo.Imginfo(Imageinfo.Extension);
            string imgName      = GetImageInfo.Imginfo(Imageinfo.FileName);
            string defPath      = GetImageInfo.MyPath("BrightConv");

            Bitmap image   = new Bitmap(img.Width, img.Height, PixelFormat.Format24bppRgb);
            double Depth   = System.Drawing.Image.GetPixelFormatSize(img.PixelFormat);
            string outName = string.Empty;

            image = BrightTransformationHelper(img, operation, plane, constOne, constTwo);

            int index = 0;

            foreach (var n in Enum.GetValues(typeof(BrightConvPlane)).Cast <BrightConvPlane>())
            {
                if (Depth == 8)
                {
                    index = 3; break;
                }                                    //ugly
                if (n == plane)
                {
                    index = (int)n; break;
                }
                ;
            }

            if (operation == "stretch")
            {
                outName = defPath + imgName + StretchContrastVariant.ElementAt(index) + "_m_" + constOne + "_E_" + constTwo + imgExtension;
            }
            else if (operation == "log")
            {
                outName = defPath + imgName + LogTransVariant.ElementAt(index) + "_c_" + constOne + imgExtension;
            }
            else if (operation == "gamma")
            {
                outName = defPath + imgName + GammaVariant.ElementAt(index) + "_c_" + constOne + "_gamma_" + constTwo + imgExtension;
            }

            Helpers.SaveOptions(image, outName, imgExtension);
        }
Exemplo n.º 29
0
        //form output name and save contrast process image to file
        private static void ContrastBlackWhiteHelper(Bitmap img, double low_in, double high_in, double low_out, double high_out, double gamma)
        {
            string imgName = GetImageInfo.Imginfo(Imageinfo.FileName);
            string defPath = GetImageInfo.MyPath("Contrast\\BlackandWhite");

            Bitmap image   = new Bitmap(img.Width, img.Height, PixelFormat.Format24bppRgb);
            string outName = String.Empty;

            image = ContrastBlackWhiteProcess(img, low_in, high_in, low_out, high_out, gamma);

            if (low_in == 0.98 && high_in == 0.99 && low_out == 0.99 && high_out == 0.99)
            {
                outName = defPath + imgName + "_ContrastDefault.png";
            }

            else if (low_out == 0 && high_out == 0)
            {
                if (gamma != 1)
                {
                    outName = defPath + imgName + "_ContrastIn[" + low_in + ";" + high_in + "]Gam_" + gamma + ".png";
                }

                else
                {
                    outName = defPath + imgName + "_ContrastIn[" + low_in + ";" + high_in + "]" + ".png";
                }
            }
            else
            {
                if (gamma != 1)
                {
                    outName = defPath + imgName + "_ContrastIn[" + low_in + ";" + high_in + "]Out[" + low_out + ";" + high_out + "]Gam_" + gamma + ".png";
                }

                else
                {
                    outName = defPath + imgName + "_ContrastIn[" + low_in + ";" + high_in + "]Out[" + low_out + ";" + high_out + "]" + ".png";
                }
            }

            Helpers.SaveOptions(image, outName, ".png");
        }
Exemplo n.º 30
0
        private static void MorphOperationShapkaProcess(Bitmap img, MorphOp operation, int[,] structureElement, string elementInf)
        {
            string imgExtension = GetImageInfo.Imginfo(Imageinfo.Extension);
            string imgName      = GetImageInfo.Imginfo(Imageinfo.FileName);
            string defPath      = GetImageInfo.MyPath("Morph");

            string outName = string.Empty;
            Bitmap image   = new Bitmap(img.Width, img.Height, PixelFormat.Format24bppRgb);

            image = MorphOperationProcess(img, operation, structureElement);

            if (string.IsNullOrEmpty(elementInf))
            {
                outName = defPath + imgName + "_" + operation.ToString() + imgExtension;
            }
            else
            {
                outName = defPath + imgName + "_" + operation.ToString() + elementInf + imgExtension;
            }
            Helpers.SaveOptions(image, outName, imgExtension);
        }