i m making a digital image processing assigment.
what i want is that i have to draw a closed selection on
a picture in a picture box..
this i have done ..but i need that all color inside
the selction then would be black and out side the selection would be white..
but i am puzzeled how to do it .. can n e one willing
to help me i m writing my code .
I m drawing the line in a perticular color and cheking it in a function mask that if this perticualr combination of color exist then till another this type of color exist make the color black i.e 0 else every other thing is black.. but its not working..
VB Code:
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, x As Single, Y As Single) If Button = 1 Then Picture1.Line (A, B)-(x, Y), RGB(100, 195, 155) A = x: B = Y End Sub Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, x As Single, Y As Single) If Button = 1 Then Picture1.Line (x, Y)-(x + 15, Y + 15) End Sub Private Sub mask(ByVal picColor As PictureBox) Picture2 = Picture1 Dim x, Y, countz As Integer Dim red, green, blue, gray As Byte GetObject picColor.Image, Len(bm), bm wid = bm.BMPWidth hgt = bm.BMPHeight ReDim bytes(0 To bm.BMPWidthBytes - 1, 0 To hgt - 1) GetBitmapBits picColor.Image, bm.BMPWidthBytes * bm.BMPHeight, bytes(0, 0) ProgressBar1.Min = 0 ProgressBar1.Max = hgt - 1 ' Convert the data to gray scale. For Y = 0 To hgt - 1 For x = 0 To wid - 1 Step 3 ' Get the current pixel value. red = bytes(x * 3, Y) green = bytes(x * 3 + 1, Y) blue = bytes(x * 3 + 2, Y) While (red = 100) And (green = 195) And (blue = 155) bytes(x * 3, Y) = 0 bytes(x * 3 + 1, Y) = 0 bytes(x * 3 + 2, Y) = 0 Wend bytes(x * 3, Y) = 255 bytes(x * 3 + 1, Y) = 255 bytes(x * 3 + 2, Y) = 255 Next x ProgressBar1.Value = Y Next Y ' Set the new pixel values. SetBitmapBits picColor.Image, _ bm.BMPWidthBytes * bm.BMPHeight, bytes(0, 0) picColor.Picture = picColor.Image End Sub





Reply With Quote