예제 #1
0
        public void Histogram(int gmax, int gmin, string selector)
        {
            float[] frequency = FrequencyDistribution();
            int     brightness, g;
            float   f;
            int     count = 0;

            for (int i = 0; i < width; i++)
            {
                for (int j = 0; j < height; j++)
                {
                    brightness = (int)(originalImage.GetPixel(i, j).GetBrightness() * 255);
                    g          = 0;
                    f          = 0;
                    for (int k = 0; k < brightness; k++)
                    {
                        f += frequency[k];
                    }

                    switch (selector)
                    {
                    case "uniform":
                        g = (int)((gmax - gmin) * f + gmin);
                        break;

                    case "degree":
                        g = (int)(Math.Pow(((Math.Pow((double)gmax, 0.333d) - Math.Pow((double)gmin, 0.333d)) * f + Math.Pow((double)gmin, 0.333d)), 3.0d));
                        break;

                    case "hyperbolic":
                        if (gmin == 0)
                        {
                            gmin = 1;
                        }
                        g = (int)((double)gmin * Math.Pow(((double)gmax / (double)gmin), f));
                        break;
                    }
                    if (g > 200)
                    {
                        count++;
                    }
                    if (g < gmin)
                    {
                        g = gmin;
                    }
                    if (g > gmax)
                    {
                        g = gmax;
                    }
                    alteredImage.SetPixel(i, j, Color.FromArgb(g, g, g));
                }
            }
            alteredImageBox.Image = alteredImage;
            HistogramForm hf = new HistogramForm(GetBrightness(originalImage), GetBrightness(new Bitmap(alteredImage)));

            hf.ShowDialog();
        }
예제 #2
0
        private void showHistogramsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            HistogramForm hf = new HistogramForm(GetBrightness(originalImage), GetBrightness(alteredImage));

            hf.ShowDialog();
        }