Esempio n. 1
0
        public void ProcessImageTest()
        {
            double[,] diag = Matrix.Magic(5);

            Bitmap input;

            new MatrixToImage()
            {
                Format = PixelFormat.Format24bppRgb
            }.Convert(diag, out input);

            GrayWorld gabor = new GrayWorld();

            // Apply the filter
            Bitmap output = gabor.Apply(input);

            double[,] actual;

            new ImageToMatrix().Convert(output, out actual);

            string str = actual.ToString(CSharpMatrixFormatProvider.InvariantCulture);

            double[,] expected =
            {
                { 0.309803921568627, 0.301960784313725, 0.333333333333333,  0.32156862745098, 0.313725490196078 },
                { 0.301960784313725, 0.325490196078431, 0.325490196078431, 0.313725490196078, 0.313725490196078 },
                { 0.329411764705882, 0.325490196078431, 0.317647058823529, 0.305882352941176, 0.305882352941176 },
                {  0.32156862745098, 0.317647058823529, 0.309803921568627, 0.305882352941176, 0.329411764705882 },
                { 0.317647058823529, 0.309803921568627, 0.301960784313725, 0.329411764705882,  0.32156862745098 }
            };

            Assert.IsTrue(expected.IsEqual(actual, 1e-6));
        }
Esempio n. 2
0
        private void grayWorldToolStripMenuItem_Click(object sender, EventArgs e)
        {
            GrayWorld grayWorld = new GrayWorld(modifiedBitmap);

            grayWorld.ApplyEffect(setImage);
            history.AddElement(grayWorld);
        }
        /// <summary>
        /// Gray World filter for color normalization.
        /// <para>Accord.NET internal call.</para>
        /// </summary>
        /// <param name="img">Image.</param>
        /// <param name="inPlace">Apply in place or not. If it is set to true return value can be omitted.</param>
        /// <returns>Processed image.</returns>
        internal static Image <TColor, TDepth> GrayWorld <TColor, TDepth>(this Image <TColor, TDepth> img, bool inPlace = true)
            where TColor : IColor
            where TDepth : struct
        {
            GrayWorld gw = new GrayWorld();

            return(img.ApplyFilter(gw, inPlace));
        }
        public GrayWorldTransformWindow()
        {
            InitializeComponent();

            Bitmap bmp = Data.Instance.Get <Bitmap>(Constants.image);
            ColorTransformCreator transformer = new GrayWorld();

            pictureBox1.Image = transformer.Transform(bmp);
        }
Esempio n. 5
0
        private void grayWorldToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (pictureBox1.Image != null)
            {
                cashBack.Push(image);
            }
            Filters filter = new GrayWorld();

            backgroundWorker1.RunWorkerAsync(filter);
        }
Esempio n. 6
0
        public void ApplyTest1()
        {
            Bitmap image = Properties.Resources.lena_color;

            // Create the Gray World filter
            var grayWorld = new GrayWorld();

            // Apply the filter
            Bitmap result = grayWorld.Apply(image);

            // ImageBox.Show(result);
            Assert.IsNotNull(result);
        }
Esempio n. 7
0
        public void ProcessImageTest2()
        {
            double[,] diag = Matrix.Magic(5);

            Bitmap input;

            new MatrixToImage()
            {
                Format = PixelFormat.Format32bppArgb
            }.Convert(diag, out input);

            Assert.AreEqual(PixelFormat.Format32bppArgb, input.PixelFormat);

            GrayWorld gabor = new GrayWorld();

            // Apply the filter
            Bitmap output = gabor.Apply(input);

            Assert.AreEqual(PixelFormat.Format32bppArgb, output.PixelFormat);

            double[,] actual;

            new ImageToMatrix().Convert(output, out actual);

            string str = actual.ToString(CSharpMatrixFormatProvider.InvariantCulture);

            double[,] expected =
            {
                { 0.937254901960784, 0.909803921568627,                 1, 0.972549019607843, 0.945098039215686 },
                { 0.913725490196078, 0.984313725490196, 0.976470588235294, 0.949019607843137, 0.941176470588235 },
                { 0.988235294117647, 0.980392156862745, 0.952941176470588, 0.925490196078431, 0.917647058823529 },
                { 0.964705882352941, 0.956862745098039, 0.929411764705882,  0.92156862745098, 0.992156862745098 },
                {  0.96078431372549, 0.933333333333333, 0.905882352941176, 0.996078431372549, 0.968627450980392 }
            };

            Assert.IsTrue(expected.IsEqual(actual, 1e-6));
        }
Esempio n. 8
0
        public mAdjustGrayWorld()
        {
            BitmapType = mFilter.BitmapTypes.None;

            filter = new GrayWorld();
        }
Esempio n. 9
0
        /// <summary>
        /// Gray World filter for color normalization.
        /// <para>Accord.NET internal call.</para>
        /// </summary>
        /// <param name="img">Image.</param>
        /// <param name="inPlace">Apply in place or not. If it is set to true return value can be omitted.</param>
        /// <returns>Processed image.</returns>
        public static Bgra <byte>[,] GrayWorld(this Bgra <byte>[,] img, bool inPlace = true)
        {
            GrayWorld gw = new GrayWorld();

            return(img.ApplyFilter(gw, inPlace));
        }
Esempio n. 10
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            IGH_Goo goo   = null;
            Image   image = new Image();

            if (!DA.GetData(0, ref goo))
            {
                return;
            }
            if (!goo.TryGetImage(ref image))
            {
                return;
            }

            int mode = 0;

            DA.GetData(1, ref mode);

            double numVal = 0.5;

            DA.GetData(2, ref numVal);

            Filter filter = new Filter();

            switch ((FilterModes)mode)
            {
            case FilterModes.GrayWorld:
                SetParameter(2);
                filter = new GrayWorld();
                break;

            case FilterModes.Histogram:
                SetParameter(2);
                filter = new Histogram();
                break;

            case FilterModes.Invert:
                SetParameter(2);
                filter = new Invert();
                break;

            case FilterModes.Stretch:
                SetParameter(2);
                filter = new Stretch();
                break;

            case FilterModes.WhitePatch:
                SetParameter(2);
                filter = new WhitePatch();
                break;

            case FilterModes.Sepia:
                SetParameter(2);
                filter = new Sepia();
                break;

            case FilterModes.RGChromacity:
                SetParameter(2);
                filter = new RGChromacity();
                break;

            case FilterModes.Brightness:
                SetParameter(2, "V", "Adjust Value", "[0-1] Unitized adjustment value");
                filter = new Brightness(numVal);
                break;

            case FilterModes.Contrast:
                SetParameter(2, "V", "Factor Value", "[0-1] Unitized adjustment value");
                filter = new Contrast(numVal);
                break;

            case FilterModes.Gamma:
                SetParameter(2, "V", "Gamma Value", "[0-1] Unitized adjustment value");
                filter = new Gamma(numVal);
                break;

            case FilterModes.Hue:
                SetParameter(2, "V", "Hue Value", "[0-1] Unitized adjustment value");
                filter = new Hue(numVal);
                break;

            case FilterModes.Saturation:
                SetParameter(2, "V", "Adjust Value", "[0-1] Unitized adjustment value");
                filter = new Saturation(numVal);
                break;
            }

            message = ((FilterModes)mode).ToString();
            UpdateMessage();

            image.Filters.Add(filter);

            DA.SetData(0, image);
            DA.SetData(1, filter);
        }