Example #1
0
        private void линейноеРастяжениеToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (pictureBox1.Enabled && !backgroundWorker1.IsBusy)
            {
                minBright = 1;
                maxBright = 0;

                for (int x = 0; x < currentImage.Width; x++)
                {
                    for (int y = 0; y < currentImage.Height; y++)
                    {
                        if (currentImage.GetPixel(x, y).GetBrightness() > maxBright)
                        {
                            maxBright = currentImage.GetPixel(x, y).GetBrightness();
                        }
                        if (currentImage.GetPixel(x, y).GetBrightness() < minBright)
                        {
                            minBright = currentImage.GetPixel(x, y).GetBrightness();
                        }
                    }
                }

                Filters filter = new LinearStretchingFilter(this);
                backgroundWorker1.RunWorkerAsync(filter);
            }
        }
Example #2
0
        private void линейноеРастяжениеToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (pictureBox1.Enabled && !backgroundWorker1.IsBusy)
            {
                minBright = 255;
                maxBright = 0;

                for (int x = 0; x < currentImage.Width; x++)
                {
                    for (int y = 0; y < currentImage.Height; y++)
                    {
                        int bright = (int)(currentImage.GetPixel(x, y).R * 0.299 + currentImage.GetPixel(x, y).G * 0.587 + currentImage.GetPixel(x, y).B * 0.114);
                        if (bright > maxBright)
                        {
                            maxBright = bright;
                        }
                        if (bright < minBright)
                        {
                            minBright = bright;
                        }
                    }
                }

                Filters filter = new LinearStretchingFilter(this);
                backgroundWorker1.RunWorkerAsync(filter);
            }
        }