public override ImageData GetResult(ImageForm_Service service, Bitmap argBitmap, List <int> args)
        {
            if (service.data.LastData() == null)
            {
                return(null);
            }

            if (service.data.LastData().Bitmap == null)
            {
                return(null);
            }

            if (argBitmap == null)
            {
                return(null);
            }

            Image <Bgra, byte> image = new Image <Bgra, byte>(service.data.LastData().Bitmap);
            Image <Bgra, byte> image2;

            if ((image.Bitmap.Width != argBitmap.Width) ||
                (image.Bitmap.Height != argBitmap.Height))
            {
                //Console.WriteLine("Przeliczam");

                Bitmap tmpbitmap = new Bitmap(image.Size.Width, image.Size.Height);

                for (int w = 0; w < tmpbitmap.Width; ++w)
                {
                    for (int h = 0; h < tmpbitmap.Height; ++h)
                    {
                        if (argBitmap.Width <= w || argBitmap.Height <= h)
                        {
                            tmpbitmap.SetPixel(w, h, Color.White);
                        }
                        else
                        {
                            tmpbitmap.SetPixel(w, h, argBitmap.GetPixel(w, h));
                        }
                    }
                }
                image2 = new Image <Bgra, byte>(tmpbitmap);
            }
            else
            {
                image2 = new Image <Bgra, byte>(argBitmap);
            }
            //Image<Bgra, byte> image2 = new Image<Bgra, byte>(tmpbitmap);

            try
            {
                Image <Bgra, byte> result = image.And(image2);

                return(new ImageData(result.Bitmap, service.data.LastData().ID));
            }
            catch
            {
                return(null);
            }
        }
        private ImageData Operation(ImageForm_Service service, List <int> args)
        {
            int p1 = args[0];
            int p2 = args[1];

            Image <Bgra, byte> image = new Image <Bgra, byte>(service.data.LastData().Bitmap);
            Image <Gray, byte> gray  = image.Convert <Gray, byte>();
            Bitmap             img   = gray.Bitmap;

            Bitmap result = new Bitmap(img.Width, img.Height, PixelFormat.Format32bppArgb);


            service.imageWindow.StartProgressBar();

            for (int i = 0; i < img.Width; ++i)
            {
                service.imageWindow.SetProgressBarValue(i * 100 / img.Width);

                for (int j = 0; j < img.Height; ++j)
                {
                    Color val = img.GetPixel(i, j);

                    result.SetPixel(i, j, Color.FromArgb((val.R >= p1 && val.R <= p2) ? val.R : 0,
                                                         (val.G >= p1 && val.G <= p2) ? val.R : 0,
                                                         (val.B >= p1 && val.B <= p2) ? val.R : 0));
                }
            }

            service.imageWindow.CloseProgressBar();
            return(new ImageData(result, service.data.LastData().ID));
        }
Esempio n. 3
0
        private ImageData Operation(ImageForm_Service service, List <int> args)
        {
            if (args == null)
            {
                return(null);
            }

            if (args.Count < 1)
            {
                return(null);
            }

            int apertureSize = args[0];

            try
            {
                Image <Bgra, byte>  image = new Image <Bgra, byte>(service.data.LastData().Bitmap);
                Image <Bgra, float> laplace;

                laplace = image.Laplace(apertureSize);

                return(new ImageData(laplace.Bitmap, service.data.LastData().ID));
            }
            catch
            {
                return(null);
            }
        }
Esempio n. 4
0
        private ImageData Operation(ImageForm_Service service, List <int> args)
        {
            if (args == null)
            {
                return(null);
            }

            if (args.Count < 2)
            {
                return(null);
            }

            double thresh        = args[0];
            double threshLinking = args[1];

            try
            {
                Image <Bgra, byte> image = new Image <Bgra, byte>(service.data.LastData().Bitmap);

                Image <Gray, byte> canny;// = new Image<Gray, byte>(gray.Width, gray.Height, new Gray(0));
                canny = image.Canny(thresh, threshLinking);

                return(new ImageData(canny.Bitmap, service.data.LastData().ID));
            }
            catch
            {
                return(null);
            }
        }
        private ImageData Operation(ImageForm_Service service, List <int> args)
        {
            if (args == null)
            {
                return(null);
            }

            if (args.Count < 1)
            {
                return(null);
            }

            //Image<Bgra, byte> image = new Image<Bgra, byte>("C:\\Users\\kptyc\\Desktop\\lena_color.png");
            //Image<Bgra, byte> image2 = new Image<Bgra, byte>("C:\\Users\\kptyc\\Desktop\\ScuiF.jpg");
            //Image<Gray, byte> gray = image.Convert<Gray, byte>();

            try
            {
                Image <Bgra, byte> image = new Image <Bgra, byte>(service.data.LastData().Bitmap);

                Image <Bgra, byte> result = image.Erode(args[0]);

                return(new ImageData(result.Bitmap, service.data.LastData().ID));
            }
            catch
            {
                return(null);
            }
        }
        private ImageData Operation(ImageForm_Service service, List <int> args)
        {
            if (args == null)
            {
                return(null);
            }

            if (args.Count < 1)
            {
                return(null);
            }

            try
            {
                Image <Bgra, byte> image = new Image <Bgra, byte>(service.data.LastData().Bitmap);

                Image <Bgra, byte> result = image.Dilate(args[0]);

                return(new ImageData(result.Bitmap, service.data.LastData().ID));
            }
            catch
            {
                return(null);
            }
        }
        private ImageData Operation(ImageForm_Service service, List <int> args)
        {
            if (args == null)
            {
                return(null);
            }

            if (args.Count < 4)
            {
                return(null);
            }

            Size  ksize  = new Size(args[0], args[1]);
            Point anchor = new Point(args[2], args[3]);

            try
            {
                Image <Bgra, byte> image = new Image <Bgra, byte>(service.data.LastData().Bitmap);
                Image <Gray, byte> gray  = image.Convert <Gray, byte>();

                Mat kernel = CvInvoke.GetStructuringElement(Emgu.CV.CvEnum.ElementShape.Rectangle, ksize, anchor);

                Image <Gray, byte> result = gray.MorphologyEx(Emgu.CV.CvEnum.MorphOp.Blackhat, kernel, anchor, 1, Emgu.CV.CvEnum.BorderType.Default, new MCvScalar(1.0));

                return(new ImageData(result.Bitmap, service.data.LastData().ID));
            }
            catch
            {
                return(null);
            }
        }
Esempio n. 8
0
        private ImageData Operation(ImageForm_Service service, List <int> args)
        {
            if (args == null)
            {
                return(null);
            }

            if (args.Count < 4)
            {
                return(null);
            }

            Size  k      = new Size(args[0], args[1]);
            Point anchor = new Point(args[2], args[3]);

            try
            {
                Image <Bgra, byte> image = new Image <Bgra, byte>(service.data.LastData().Bitmap);
                //Image<Gray, byte> gray = image.Convert<Gray, byte>();
                //Image<Gray, byte> blur = new Image<Gray, byte>(gray.Width, gray.Height, new Gray(0));
                //CvInvoke.Blur(gray, blur, k, anchor);

                Image <Bgra, byte> blur = new Image <Bgra, byte>(image.Width, image.Height);
                CvInvoke.Blur(image, blur, k, anchor);

                return(new ImageData(blur.Bitmap, service.data.LastData().ID));
            }
            catch
            {
                return(null);
            }
        }
Esempio n. 9
0
        private ImageData Operation(ImageForm_Service service, List <int> args)
        {
            if (args == null)
            {
                return(null);
            }

            if (args.Count < 1)
            {
                return(null);
            }



            int ksize = args[0];

            try
            {
                Image <Bgra, byte> image = new Image <Bgra, byte>(service.data.LastData().Bitmap);
                Image <Bgra, byte> blur  = new Image <Bgra, byte>(image.Width, image.Height);

                CvInvoke.MedianBlur(image, blur, ksize);

                return(new ImageData(blur.Bitmap, service.data.LastData().ID));
            }
            catch
            {
                return(null);
            }
        }
        public override ImageData GetResult(ImageForm_Service service, List <int> args)
        {
            if (service == null)
            {
                return(null);
            }

            if (service.data == null)
            {
                return(null);
            }

            if (service.data.LastData() == null)
            {
                return(null);
            }

            if (service.data.LastData().Bitmap == null)
            {
                return(null);
            }

            //if (service.data.LastData().Ready)
            //    return null;

            return(Operation(service, args));
        }
        private ImageData Operation_Optimized(ImageForm_Service service, List <int> args)
        {
            if (args == null)
            {
                return(null);
            }

            if (args.Count < 1)
            {
                return(null);
            }

            int p1 = args[0];
            int p2 = args[1];

            try
            {
                Image <Bgra, byte> image = new Image <Bgra, byte>(service.data.LastData().Bitmap);
                Image <Gray, byte> gray  = image.Convert <Gray, byte>();

                Image <Gray, byte> binarize = new Image <Gray, byte>(gray.Width, gray.Height, new Gray(0));

                CvInvoke.Threshold(gray, binarize, p1, p2, Emgu.CV.CvEnum.ThresholdType.Binary);

                return(new ImageData(binarize.Bitmap, service.data.LastData().ID));
            }
            catch
            {
                return(null);
            }
        }
Esempio n. 12
0
        public override ImageData GetResult(ImageForm_Service service)
        {
            if (service.data.LastData() == null)
            {
                return(null);
            }

            if (service.data.LastData().Bitmap == null)
            {
                return(null);
            }

            //if (service.data.LastData().Ready)
            //    return null;


            //if (!before.Ready)
            //    before.RecalculateHistograms(ref pbar);

            service.imageWindow.StartProgressBar();

            Bitmap    bitmap = service.data.LastData().Bitmap;
            ImageData result = new ImageData();

            Bitmap newBitmap = new Bitmap(bitmap.Width, bitmap.Height, bitmap.PixelFormat);

            for (int h = 0; h < bitmap.Height; ++h)
            {
                service.imageWindow.SetProgressBarValue(h * 100 / bitmap.Height);

                for (int w = 0; w < bitmap.Width; ++w)
                {
                    Color newPixel = Color.FromArgb(bitmap.GetPixel(w, h).A, (255 - bitmap.GetPixel(w, h).R), (255 - bitmap.GetPixel(w, h).G), (255 - bitmap.GetPixel(w, h).B));
                    newBitmap.SetPixel(w, h, newPixel);

                    result.data.SumUp(newPixel.R);
                    result.data.SumUp(newPixel.G);
                    result.data.SumUp(newPixel.B);

                    result.data_A.SumUp(newPixel.A);
                    result.data_R.SumUp(newPixel.R);
                    result.data_G.SumUp(newPixel.G);
                    result.data_B.SumUp(newPixel.B);
                }
            }
            result.data.SetLeast();
            result.data_A.SetLeast();
            result.data_R.SetLeast();
            result.data_G.SetLeast();
            result.data_B.SetLeast();
            result.Bitmap = newBitmap;

            result.SetReady();
            service.imageWindow.CloseProgressBar();

            return(result);
        }
        private ImageData Operation(ImageForm_Service service, List <int> args)
        {
            if (args == null)
            {
                return(null);
            }

            if (args.Count < 2)
            {
                return(null);
            }

            if (service.data.LastData() == null)
            {
                return(null);
            }

            if (service.data.LastData().Bitmap == null)
            {
                return(null);
            }

            int radio = args[0];
            int value = args[1];

            Bitmap bitmap = service.data.LastData().Bitmap;
            Bitmap result = new Bitmap(bitmap.Width, bitmap.Height, PixelFormat.Format32bppArgb);

            Point center = new Point(bitmap.Width / 2, bitmap.Height / 2);

            for (int w = 0; w < bitmap.Width; ++w)
            {
                for (int h = 0; h < bitmap.Height; ++h)
                {
                    int   currentRadio = CalculateRadio(new Point(w, h), center);
                    Color pixel        = bitmap.GetPixel(w, h);

                    if (currentRadio > radio)
                    {
                        result.SetPixel(w, h, pixel);
                        continue;
                    }


                    result.SetPixel(w, h, Color.FromArgb(
                                        pixel.A,
                                        (pixel.R - value > 0) ? pixel.R - value : 0,
                                        (pixel.G - value > 0) ? pixel.G - value : 0,
                                        (pixel.B - value > 0) ? pixel.B - value : 0
                                        ));
                }
            }

            return(new ImageData(result, service.data.LastData().ID));
        }
Esempio n. 14
0
        public override void Start(Program program, ImageForm_Service service, IOperation operation, string operationName)
        {
            if (program == null)
            {
                return;
            }
            if (service == null)
            {
                return;
            }
            if (operation == null)
            {
                return;
            }
            if (operationName == null)
            {
                return;
            }

            this.PROGRAM         = program;
            this.SERVICE         = service;
            this.OPERATION       = operation;
            this.OperationIDName = operationName;

            if (SERVICE.data == null)
            {
                return;
            }
            if (SERVICE.data.LastData() == null)
            {
                return;
            }


            widthValue.Maximum = 64;
            widthValue.Minimum = 0;

            HeightValue.Maximum = 64;
            HeightValue.Minimum = 0;

            xposValue.Maximum = 64;
            xposValue.Minimum = 0;

            yposValue.Maximum = 64;
            yposValue.Minimum = 0;

            ReloadLanguage();
            ReloadColorSet();

            this.form.Show();
            wait = false;
        }
Esempio n. 15
0
        public override void Start(Program program, ImageForm_Service service, IOperation operation, string operationName)
        {
            if (program == null)
            {
                return;
            }
            if (service == null)
            {
                return;
            }
            if (operation == null)
            {
                return;
            }
            if (operationName == null)
            {
                return;
            }

            this.PROGRAM         = program;
            this.SERVICE         = service;
            this.OPERATION       = operation;
            this.OperationIDName = operationName;

            if (SERVICE.data == null)
            {
                return;
            }
            if (SERVICE.data.LastData() == null)
            {
                return;
            }

            int tmp = (SERVICE.data.LastData().Bitmap.Width > SERVICE.data.LastData().Bitmap.Height) ?
                      SERVICE.data.LastData().Bitmap.Width * 3 / 4 :
                      SERVICE.data.LastData().Bitmap.Height * 3 / 4;

            Radio.Maximum = tmp;
            Radio.Value   = tmp / 2;
            Radio.Minimum = 0;

            Value.Maximum = 255;
            Value.Value   = 128;
            Value.Minimum = 0;

            ReloadLanguage();
            ReloadColorSet();

            this.form.Show();
            wait = false;
        }
Esempio n. 16
0
        public override void Start(Program program, ImageForm_Service service, IOperation operation, string operationName)
        {
            if (program == null)
            {
                return;
            }
            if (service == null)
            {
                return;
            }
            if (operation == null)
            {
                return;
            }
            if (operationName == null)
            {
                return;
            }

            this.PROGRAM         = program;
            this.SERVICE         = service;
            this.OPERATION       = operation;
            this.OperationIDName = operationName;

            if (SERVICE.data == null)
            {
                return;
            }
            if (SERVICE.data.LastData() == null)
            {
                return;
            }


            value.Maximum = SERVICE.data.LastData().Bitmap.Width * 3;
            value.Minimum = 3;

            MaxValue.Maximum = 255;
            MaxValue.Minimum = 0;


            //MaxValue.Value = SERVICE.data.LastData().Bitmap.Width;
            MaxValue.Value = 100;
            value.Value    = MaxValue.Value / 2;

            ReloadLanguage();
            ReloadColorSet();

            this.form.Show();
            wait = false;
        }
Esempio n. 17
0
        private ImageData Operation(ImageForm_Service service, List <int> args)
        {
            if (args == null)
            {
                return(null);
            }

            if (args.Count < 1)
            {
                return(null);
            }

            int kSize = args[0];

            float[,] k = new float[kSize, kSize];

            int c = 0;

            for (int i = 1; i < args.Count;)
            {
                int r = 0;
                for ( ; r < kSize; ++r, ++i)
                {
                    k[c, r] = args[i];
                }
                ++c;
            }

            try
            {
                Image <Bgra, byte> image = new Image <Bgra, byte>(service.data.LastData().Bitmap);
                Image <Gray, byte> gray  = image.Convert <Gray, byte>();

                //Image<Gray, Byte> image = new Image<Gray, byte>(300, 400);
                //gray.SetRandUniform(new MCvScalar(0.0), new MCvScalar(255.0)); // <<<<<<<<<<< Ciekawe

                //int apertureSize = 11;
                //Image<Gray, float> laplace = gray.Laplace(apertureSize);


                ConvolutionKernelF  kernel     = new ConvolutionKernelF(k);
                Image <Gray, float> convoluted = gray * kernel;
                //Image<Bgra, float> convoluted = image * kernel;

                return(new ImageData(convoluted.Bitmap, service.data.LastData().ID));
            }
            catch
            {
                return(null);
            }
        }
Esempio n. 18
0
        public override void Start(Program program, ImageForm_Service service, IOperation operation, string operationName)
        {
            if (program == null)
            {
                return;
            }
            if (service == null)
            {
                return;
            }
            if (operation == null)
            {
                return;
            }
            if (operationName == null)
            {
                return;
            }

            this.PROGRAM         = program;
            this.SERVICE         = service;
            this.OPERATION       = operation;
            this.OperationIDName = operationName;

            if (SERVICE.data == null)
            {
                return;
            }
            if (SERVICE.data.LastData() == null)
            {
                return;
            }


            xOrder.Maximum = 1;
            xOrder.Minimum = 0;

            yOrder.Maximum = 1;
            yOrder.Minimum = 0;

            apertureSize.Maximum = 31;
            apertureSize.Minimum = 1;


            ReloadLanguage();
            ReloadColorSet();

            this.form.Show();
            wait = false;
        }
Esempio n. 19
0
        private ImageData Operation(ImageForm_Service service)
        {
            try
            {
                Image <Bgra, byte> image = new Image <Bgra, byte>(service.data.LastData().Bitmap);
                Image <Gray, byte> gray  = image.Convert <Gray, byte>();

                return(new ImageData(gray.Bitmap, service.data.LastData().ID));
            }
            catch
            {
                return(null);
            }
        }
        public override ImageData GetResult(ImageForm_Service service)
        {
            if (service.data.LastData() == null)
            {
                return(null);
            }

            if (service.data.LastData().Bitmap == null)
            {
                return(null);
            }

            if (service.data.LastData().Ready)
            {
                return(null);
            }

            service.imageWindow.StartProgressBar();
            Bitmap    bitmap       = service.data.LastData().Bitmap;
            ImageData newImageData = service.data.LastData();

            for (int h = 0; h < bitmap.Height; ++h)
            {
                service.imageWindow.SetProgressBarValue(h * 100 / bitmap.Height);

                for (int w = 0; w < bitmap.Width; ++w)
                {
                    newImageData.data.SumUp(bitmap.GetPixel(w, h).R);
                    newImageData.data.SumUp(bitmap.GetPixel(w, h).G);
                    newImageData.data.SumUp(bitmap.GetPixel(w, h).B);

                    newImageData.data_A.SumUp(bitmap.GetPixel(w, h).A);
                    newImageData.data_R.SumUp(bitmap.GetPixel(w, h).R);
                    newImageData.data_G.SumUp(bitmap.GetPixel(w, h).G);
                    newImageData.data_B.SumUp(bitmap.GetPixel(w, h).B);
                }
            }
            newImageData.data.SetLeast();
            newImageData.data_A.SetLeast();
            newImageData.data_R.SetLeast();
            newImageData.data_G.SetLeast();
            newImageData.data_B.SetLeast();

            newImageData.SetReady();

            service.imageWindow.CloseProgressBar();

            return(newImageData);
        }
Esempio n. 21
0
        public override void Start(Program program, ImageForm_Service service, IOperation operation, string operationName)
        {
            if (program == null)
            {
                return;
            }
            if (service == null)
            {
                return;
            }
            if (operation == null)
            {
                return;
            }
            if (operationName == null)
            {
                return;
            }

            this.PROGRAM         = program;
            this.SERVICE         = service;
            this.OPERATION       = operation;
            this.OperationIDName = operationName;

            if (SERVICE.data == null)
            {
                return;
            }
            if (SERVICE.data.LastData() == null)
            {
                return;
            }

            if (!SERVICE.data.LastData().Ready)
            {
                SERVICE.ImageOperation("RecalculateHistogramData_tsmi");
            }

            this.Histogram.ReloadHistogram(SERVICE.data.LastData().data.data);

            MaxValue.Value = SERVICE.data.LastData().data.maxValue;
            value.Value    = MaxValue.Value / 2;

            ReloadLanguage();
            ReloadColorSet();

            this.form.Show();
            wait = false;
        }
        private ImageData Operation(ImageForm_Service service, List <int> args)
        {
            if (args == null)
            {
                return(null);
            }

            if (args.Count < 1)
            {
                return(null);
            }

            Bitmap img    = service.data.LastData().Bitmap;
            double levels = args[0];

            double sr, sg, sb;
            int    dr, dg, db;

            service.imageWindow.StartProgressBar();

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

            for (int i = 0; i < img.Width; ++i)
            {
                service.imageWindow.SetProgressBarValue(i * 100 / img.Width);

                for (int j = 0; j < img.Height; ++j)
                {
                    Color val = img.GetPixel(i, j);

                    sr = val.R / 255.0;
                    sg = val.G / 255.0;
                    sb = val.B / 255.0;

                    dr = (int)(255 * Math.Round(sr * levels) / levels);
                    dg = (int)(255 * Math.Round(sg * levels) / levels);
                    db = (int)(255 * Math.Round(sb * levels) / levels);
                    result.SetPixel(i, j, Color.FromArgb(dr, dg, db));
                }
            }
            service.imageWindow.CloseProgressBar();
            return(new ImageData(result, service.data.LastData().ID));
        }
        private ImageData Operation(ImageForm_Service service, List <int> args)
        {
            if (args == null)
            {
                return(null);
            }

            if (args.Count < 1)
            {
                return(null);
            }

            int    BlockSize = args[0];
            double param2    = args[1];

            try
            {
                Image <Bgra, byte> image = new Image <Bgra, byte>(service.data.LastData().Bitmap);
                Image <Gray, byte> gray  = image.Convert <Gray, byte>();

                Image <Gray, byte> binarize = new Image <Gray, byte>(gray.Width, gray.Height, new Gray(0));

                if (BlockSize <= 1)
                {
                    BlockSize = 3;
                }

                if (BlockSize % 2 != 1)
                {
                    ++BlockSize;
                }

                CvInvoke.AdaptiveThreshold(gray, binarize, 255, Emgu.CV.CvEnum.AdaptiveThresholdType.MeanC, Emgu.CV.CvEnum.ThresholdType.Binary, BlockSize, param2);

                return(new ImageData(binarize.Bitmap, service.data.LastData().ID));
            }
            catch
            {
                return(null);
            }
        }
Esempio n. 24
0
        private ImageData Operation(ImageForm_Service service, List <int> args)
        {
            if (args == null)
            {
                return(null);
            }

            if (args.Count < 4)
            {
                return(null);
            }

            Size   k      = new Size(args[0], args[1]);
            double sigmaX = args[2];
            double sigmaY = args[3];

            // Gray Version
            //Image<Bgra, byte> image = new Image<Bgra, byte>("C:\\Users\\kptyc\\Desktop\\lena_color.png");
            //Image<Gray, byte> gray = image.Convert<Gray, byte>();
            //Image<Gray, byte> blur = new Image<Gray, byte>(gray.Width, gray.Height, new Gray(0));
            //CvInvoke.GaussianBlur(gray, blur, k, s);

            try
            {
                Image <Bgra, byte> image = new Image <Bgra, byte>(service.data.LastData().Bitmap);
                Image <Bgra, byte> blur  = new Image <Bgra, byte>(image.Width, image.Height);

                CvInvoke.GaussianBlur(image, blur, k, sigmaX, sigmaY);


                return(new ImageData(blur.Bitmap, service.data.LastData().ID));
            }
            catch
            {
                return(null);
            }
        }
Esempio n. 25
0
        private ImageData Operation(ImageForm_Service service, List <int> args)
        {
            if (args == null)
            {
                return(null);
            }

            if (args.Count < 3)
            {
                return(null);
            }

            int xOrder       = args[0];
            int yOrder       = args[1];
            int apertureSize = args[2];

            try
            {
                Image <Bgra, byte>  image = new Image <Bgra, byte>(service.data.LastData().Bitmap);
                Image <Bgra, float> sobel;

                sobel = image.Sobel(xOrder, yOrder, apertureSize);
                // xOrder >= 0
                // yOrder >= 0
                // xOrder + yOrder == 1   ???

                // apertureSize % 2 == 1
                // apertureSize <= 31

                return(new ImageData(sobel.Bitmap, service.data.LastData().ID));
            }
            catch
            {
                return(null);
            }
        }
Esempio n. 26
0
        public override ImageData GetResult(ImageForm_Service service)
        {
            if (service.data.LastData() == null)
            {
                return(null);
            }

            if (service.data.LastData().Bitmap == null)
            {
                return(null);
            }

            try
            {
                Image <Bgra, byte> image  = new Image <Bgra, byte>(service.data.LastData().Bitmap);
                Image <Bgra, byte> result = image.Not();

                return(new ImageData(result.Bitmap, service.data.LastData().ID));
            }
            catch
            {
                return(null);
            }
        }
Esempio n. 27
0
 public override ImageData GetResult(ImageForm_Service x, List <int> args)
 => throw new NotImplementedException();
Esempio n. 28
0
 public void SetProgramReference(ImageForm_Service service)
 {
     result.SERVICE = service;
 }
        public override ImageData GetResult(ImageForm_Service service)
        {
            if (service.data.LastData() == null)
            {
                return(null);
            }

            if (service.data.LastData().Bitmap == null)
            {
                return(null);
            }

            if (!service.data.LastData().Ready)
            {
                service.ImageOperation("RecalculateHistogramData_tsmi");
            }


            Bitmap oldBitmap = service.data.LastData().Bitmap;
            Bitmap newBitmap = new Bitmap(oldBitmap.Width, oldBitmap.Height, service.data.LastData().Bitmap.PixelFormat);

            List <int> LUTred   = CalculateLUT(service.data.LastData().data_R);
            List <int> LUTgreen = CalculateLUT(service.data.LastData().data_G);
            List <int> LUTblue  = CalculateLUT(service.data.LastData().data_B);

            HistogramData general = new HistogramData();
            HistogramData red     = new HistogramData();
            HistogramData green   = new HistogramData();
            HistogramData blue    = new HistogramData();

            service.imageWindow.StartProgressBar();

            for (int h = 0; h < oldBitmap.Height; ++h)
            {
                service.imageWindow.SetProgressBarValue(h * 100 / oldBitmap.Height);

                for (int w = 0; w < oldBitmap.Width; ++w)
                {
                    Color pixel    = oldBitmap.GetPixel(w, h);
                    Color newPixel = Color.FromArgb(pixel.A, LUTred[pixel.R], LUTgreen[pixel.G], LUTblue[pixel.B]);
                    newBitmap.SetPixel(w, h, newPixel);

                    general.SumUp(newPixel.R);
                    general.SumUp(newPixel.G);
                    general.SumUp(newPixel.B);

                    red.SumUp(newPixel.R);
                    green.SumUp(newPixel.G);
                    blue.SumUp(newPixel.B);
                }
            }
            general.SetLeast();
            red.SetLeast();
            green.SetLeast();
            blue.SetLeast();

            ImageData after = new ImageData(newBitmap, service.data.LastData().ID)
            {
                data   = general,
                data_A = service.data.LastData().data_A,
                data_R = red,
                data_G = green,
                data_B = blue
            };

            after.SetReady();

            service.imageWindow.CloseProgressBar();
            return(after);
        }
 public override ImageData GetResult(ImageForm_Service service)
 => throw new NotImplementedException();