コード例 #1
0
 private void Negation_Click(object sender, EventArgs e)
 {
     for (int i = 0; i < pictureBox1.Image.Width; i++)
     {
         for (int j = 0; j < pictureBox1.Image.Height; j++)
         {
             Color newColor = picture.Bitmap.GetPixel(i, j);
             newColor = Color.FromArgb(NumberNormalizer.Normalize(255 - newColor.R), NumberNormalizer.Normalize(255 - newColor.G), NumberNormalizer.Normalize(255 - newColor.B));
             picture.Bitmap.SetPixel(i, j, newColor);
         }
     }
     pictureBox1.Refresh();
 }
コード例 #2
0
        private void brightness_Click(object sender, EventArgs e)
        {
            int constant = Convert.ToInt32(brightnessTextBox.Text);

            for (int i = 0; i < pictureBox1.Image.Width; i++)
            {
                for (int j = 0; j < pictureBox1.Image.Height; j++)
                {
                    Color newColor = picture.Bitmap.GetPixel(i, j);
                    newColor = Color.FromArgb(NumberNormalizer.Normalize(newColor.R + constant), NumberNormalizer.Normalize(newColor.G + constant), NumberNormalizer.Normalize(newColor.B + constant));
                    picture.Bitmap.SetPixel(i, j, newColor);
                }
            }
            pictureBox1.Refresh();
        }
コード例 #3
0
 private int[,] createNeighbours(int i, int j)
 {
     int[,] neighbours = new int[Kernel.MAXINDEX, Kernel.MAXINDEX];
     for (int x = 0; x < currentKernel.sizeX; x++)
     {
         for (int y = 0; y < currentKernel.sizeY; y++)
         {
             neighbours[x, y] = picture.Bitmap.GetPixel(
                 NumberNormalizer.Normalize(i - currentKernel.anchor.Item1 + x, picture.Bitmap.Width),
                 NumberNormalizer.Normalize(j - currentKernel.anchor.Item2 + y, picture.Bitmap.Height)
                 ).ToArgb();
         }
     }
     return(neighbours);
 }
コード例 #4
0
        private void Contrast_Click(object sender, EventArgs e)
        {
            double constant = Convert.ToDouble(ContrastTextBox.Text);

            for (int i = 0; i < pictureBox1.Image.Width; i++)
            {
                for (int j = 0; j < pictureBox1.Image.Height; j++)
                {
                    Color newColor = picture.Bitmap.GetPixel(i, j);
                    newColor = Color.FromArgb(NumberNormalizer.Normalize(Math.Pow(newColor.R, constant)),
                                              NumberNormalizer.Normalize(Math.Pow(newColor.G, constant)),
                                              NumberNormalizer.Normalize(Math.Pow(newColor.B, constant)));
                    picture.Bitmap.SetPixel(i, j, newColor);
                }
            }
            pictureBox1.Refresh();
        }
コード例 #5
0
        private void applyContrastButton_Click(object sender, EventArgs e)
        {
            double constant = Convert.ToDouble(TrueContrastTextBox.Text);
            Bitmap newImage = new Bitmap(picture.Bitmap.Width, picture.Bitmap.Height);

            for (int i = 0; i < pictureBox1.Image.Width; i++)
            {
                for (int j = 0; j < pictureBox1.Image.Height; j++)
                {
                    Color newColor = picture.Bitmap.GetPixel(i, j);
                    newColor = Color.FromArgb(NumberNormalizer.Normalize((newColor.R - 127) * constant + 127), NumberNormalizer.Normalize((newColor.G - 127) * constant + 127), NumberNormalizer.Normalize((newColor.B - 127) * constant + 127));
                    newImage.SetPixel(i, j, newColor);
                }
            }
            picture.Bitmap    = newImage;
            pictureBox1.Image = newImage;
            pictureBox1.Refresh();
        }
コード例 #6
0
        public int calculate(int[,] neighbours)
        {
            int valR = 0;
            int valG = 0;
            int valB = 0;

            for (int i = 0; i < sizeX; i++)
            {
                for (int j = 0; j < sizeY; j++)
                {
                    Color pix = Color.FromArgb(neighbours[i, j]);
                    valR += kernel[i, j] * pix.R;
                    valG += kernel[i, j] * pix.G;
                    valB += kernel[i, j] * pix.B;
                }
            }
            valR = NumberNormalizer.Normalize(valR / divisor + offset);
            valG = NumberNormalizer.Normalize(valG / divisor + offset);
            valB = NumberNormalizer.Normalize(valB / divisor + offset);
            Color pixel = Color.FromArgb(valR, valG, valB);

            return(pixel.ToArgb());
        }