Exemple #1
0
        private void resizeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int tempNewWidth  = Convert.ToInt32(Prompt.ShowDialog("Enter the new width", "Width"));
            int tempNewHeight = Convert.ToInt32(Prompt.ShowDialog("Enter the new height", "Height"));

            resizeImage(ref source, ref result, tempNewWidth, tempNewHeight);
            outputPic.Image = result;
        }
Exemple #2
0
        private void contrastToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Bitmap tempImage     = source;
            int    contrastValue = Convert.ToInt32(Prompt.ShowDialog("Enter contrast value", "Contrast"));

            result = new Bitmap(source.Width, source.Height); //initalize the image
            ImageProcess.EqualisationColored(tempImage, ref source, ref result, contrastValue);
            outputPic.Image = result;
        }
Exemple #3
0
        private void thresholdingToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string promptValue = Prompt.ShowDialog("Enter the threshold value (0-255)", "Threshold");

            result = new Bitmap(source.Width, source.Height); //initalize the image
            Color pixel;

            for (int x = 0; x < source.Width; x++)
            {
                for (int y = 0; y < source.Height; y++)
                {
                    pixel = source.GetPixel(x, y);
                    int   grey      = (int)(pixel.R * 0.33 + pixel.G * 0.33 + pixel.B * 0.34);
                    int   threshold = Convert.ToInt32(promptValue);
                    Color tempColor = Color.FromArgb(255, 255, 255);
                    if (grey < threshold)
                    {
                        tempColor = Color.FromArgb(0, 0, 0);
                    }
                    result.SetPixel(x, y, tempColor);
                }
            }
            outputPic.Image = result;
        }
Exemple #4
0
 private void mergeImagesToolStripMenuItem_Click(object sender, EventArgs e)
 {
     aboutToImageSubtract = true;
     tempVal = Convert.ToInt32(Prompt.ShowDialog("Enter value threshold for color subtraction. Then select a color from the first image.", "Image Subtraction"));
 }
Exemple #5
0
        private void rotateToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //newX = (int)((x) * Math.Cos(rotation) + (y) * (-Math.Sin(rotation)));
            //newY = (int)(((x) * Math.Sin(rotation) + (y) * Math.Cos(rotation)));
            double rotation = Math.PI / 180 * Convert.ToDouble(Prompt.ShowDialog("How many degrees you want to rotate the image?", "Rotation"));

            result = new Bitmap(source.Width, source.Height); //initalize the image
            Color pixel;
            int   newX, newY, transX, transY, cX, cY;

            for (int x = 0; x < source.Width / 2; x++)
            {
                for (int y = 0; y < source.Height / 2; y++)
                {
                    //quadrant 1
                    pixel  = source.GetPixel(x, y);
                    newX   = (int)((x - source.Width / 2) * Math.Cos(rotation) + (y - source.Height / 2) * (-Math.Sin(rotation)));
                    newY   = (int)(((x - source.Width / 2) * Math.Sin(rotation) + (y - source.Height / 2) * Math.Cos(rotation)));
                    transX = newX + source.Width / 2;
                    transY = newY + source.Height / 2;
                    if (transX >= 0 && transX < source.Width && transY >= 0 && transY < source.Height)
                    {
                        result.SetPixel(transX, transY, pixel);
                    }
                    //quadrant 2
                    cX     = source.Width / 2 + x;
                    cY     = y;
                    pixel  = source.GetPixel(cX, cY);
                    newX   = (int)((cX - source.Width / 2) * Math.Cos(rotation) + (cY - source.Height / 2) * (-Math.Sin(rotation)));
                    newY   = (int)(((cX - source.Width / 2) * Math.Sin(rotation) + (cY - source.Height / 2) * Math.Cos(rotation)));
                    transX = newX + source.Width / 2;
                    transY = newY + source.Height / 2;
                    if (transX >= 0 && transX < source.Width && transY >= 0 && transY < source.Height)
                    {
                        result.SetPixel(transX, transY, pixel);
                    }
                    //quadrant 3
                    cX     = x;
                    cY     = source.Height / 2 + y;
                    pixel  = source.GetPixel(cX, cY);
                    newX   = (int)((cX - source.Width / 2) * Math.Cos(rotation) + (cY - source.Height / 2) * (-Math.Sin(rotation)));
                    newY   = (int)(((cX - source.Width / 2) * Math.Sin(rotation) + (cY - source.Height / 2) * Math.Cos(rotation)));
                    transX = newX + source.Width / 2;
                    transY = newY + source.Height / 2;
                    if (transX >= 0 && transX < source.Width && transY >= 0 && transY < source.Height)
                    {
                        result.SetPixel(transX, transY, pixel);
                    }
                    //quadrant 4
                    cX     = source.Width / 2 + x;
                    cY     = source.Height / 2 + y;
                    pixel  = source.GetPixel(cX, cY);
                    newX   = (int)((cX - source.Width / 2) * Math.Cos(rotation) + (cY - source.Height / 2) * (-Math.Sin(rotation)));
                    newY   = (int)(((cX - source.Width / 2) * Math.Sin(rotation) + (cY - source.Height / 2) * Math.Cos(rotation)));
                    transX = newX + source.Width / 2;
                    transY = newY + source.Height / 2;
                    if (transX >= 0 && transX < source.Width && transY >= 0 && transY < source.Height)
                    {
                        result.SetPixel(transX, transY, pixel);
                    }
                }
            }
            outputPic.Image = result;
        }