hi everyone .I have this code to convert color image to grayscale image but the problem is that the image after converting does not display on the picturebox2 . I am using visualbasic.net 2010
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim pic As Bitmap = New Bitmap(PictureBox1.Image)
Dim x As Integer
Dim y As Integer
x = pic.Width
y = pic.Height
Dim gray = New Bitmap(pic.Width, pic.Height)
Dim red As Integer
Dim green As Integer
Dim blue As Integer
For x = 0 To (pic.Width) - 1
For y = 0 To (pic.Height) - 1
Dim r As Color = pic.GetPixel(x, y)
red = r.R
green = r.G
blue = r.B
Dim d As Integer
d = CInt((red + green + blue) / 3)
Dim c1 As Integer = CInt(Math.Round(d))
gray.SetPixel(x, y, Color.FromArgb(c1, c1, c1))
PictureBox2.Image = gray
Next
Next
End Sub