Example #1
0
        //Removes pixels of a certain color
        private void RemoveColor(PixelState[,] pixels, GridRemovalSettings gridSettings, PixelState pxState)
        {
            for (int x = 0; x < bmp.Width; x++)
            {
                for (int y = 0; y < bmp.Height; y++)
                {
                    int value = discretize.DiscretizeValueForeground(x, y, gridSettings.color);

                    if (!discretize.PixelIsOn(value, gridSettings))
                    {
                        pixels[x, y] = pxState;
                    }
                }
            }
        }
Example #2
0
        public void MakeHistogramData()
        {
            Bitmap     bmp    = new Bitmap(image);
            BitmapData bmData = bmp.LockBits(new Rectangle(0, 0, image.Width, image.Height), ImageLockMode.ReadOnly, image.PixelFormat);

            for (int i = 0; i < image.Width; i++)
            {
                for (int j = 0; j < image.Height; j++)
                {
                    int value;

                    if (settings.discretizeMethod == DiscretizeMethod.DiscretizeForeground)
                    {
                        value = discretize.DiscretizeValueForeground(i, j, bmData);
                    }
                    else
                    {
                        value = discretize.DiscretizeValue(i, j, bmData);
                    }

                    histogramData[value]++;
                }

                progressUpdated((double)i / ((double)image.Width - 1));
            }

            bmp.UnlockBits(bmData);

            //Now scale the data logarithmically

            int pixels = image.Width * image.Height;

            for (int i = 0; i < histogramData.Length; i++)
            {
                int point = (int)((innerPanel.Height) * (1.0 - Math.Log(histogramData[i]) / Math.Log(pixels)) + 0.5);

                if (point < 0)
                {
                    point = 0;
                }
                else if (point > innerPanel.Height)
                {
                    point = innerPanel.Height;
                }

                displayData[i] = point;
            }
        }