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
        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.º 6
0
        //create CheckerBoard

        //n - pixels per cell
        public static void CheckerBoard(int n, OutType type)
        {
            string defPath = GetImageInfo.MyPath("Rand");

            int[,] result = new int[n * 8, n * 8]; //8 -default cells
            result        = CheckerBoardHelper(n, 8, 8);

            string outName = defPath + "checkerboardClassik_" + "pixelsPerCell_" + n + ".png";

            MoreHelpers.WriteImageToFile(result, result, result, outName, type);
        }
Exemplo n.º 7
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.º 8
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.º 9
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.º 10
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.º 11
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.º 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
        //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.º 14
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.º 15
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.º 16
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.º 17
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.º 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
        //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.º 20
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.º 21
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.º 22
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.º 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
        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.º 25
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.º 26
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.º 27
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.º 28
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.º 29
0
        private static double[] ReadLut(string lutName, [CallerMemberName] string callName = "")
        {
            int index = 0;

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

            string        lutPath = GetImageInfo.LutPath(PreparedLutPath.ElementAt(index) + lutName);
            string        line;
            int           count = 0;
            List <string> temp  = new List <string>();

            using (StreamReader lutFile = new StreamReader(lutPath))
            {
                while ((line = lutFile.ReadLine()) != null)
                {
                    temp.Add(line);
                    count++;
                }
            }

            string concat = String.Join(" ", temp.ToArray()).Replace(" ", "");

            temp = new List <string>();
            foreach (char s in concat)
            {
                temp.Add(s.ToString());
            }

            double[] lut = new double[temp.Count];
            for (int i = 0; i < temp.Count; i++)
            {
                lut[i] = Convert.ToDouble(temp[i]);
            }

            return(lut);
        }
Exemplo n.º 30
0
        //rows, cols, n - pixels per cell
        public static void CheckerBoard(int n, int rows, int cols, OutType type)
        {
            string defPath = GetImageInfo.MyPath("Rand");

            int[,] result = new int[n * rows, n *cols];

            if (rows > 0 && cols > 0)
            {
                result = CheckerBoardHelper(n, rows, cols);

                string outName = defPath + "checkerboard_" + "rows_" + rows + "_cols_" + cols + "_pixelsPerCell_" + n + ".png";

                MoreHelpers.WriteImageToFile(result, result, result, outName, type);
            }
            else
            {
                Console.WriteLine("r and c must be positive values greater than 1. Method: CheckerBoard");
            }
        }