Results 1 to 10 of 10

Thread: How to get the pixel and chek them for a pirticular color

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member Kirun's Avatar
    Join Date
    Oct 2001
    Location
    Karachi , Pakistan
    Posts
    333

    Question How to get the pixel and chek them for a pirticular color

    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:
    1. Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, x As Single, Y As Single)
    2.     If Button = 1 Then Picture1.Line (A, B)-(x, Y), RGB(100, 195, 155)
    3.     A = x: B = Y
    4. End Sub
    5.  
    6. Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, x As Single, Y As Single)
    7.     If Button = 1 Then Picture1.Line (x, Y)-(x + 15, Y + 15)
    8. End Sub
    9.  
    10. Private Sub mask(ByVal picColor As PictureBox)
    11.     Picture2 = Picture1
    12.  Dim x, Y, countz As Integer
    13.  Dim red, green, blue, gray As Byte
    14.     GetObject picColor.Image, Len(bm), bm
    15.     wid = bm.BMPWidth
    16.     hgt = bm.BMPHeight
    17.     ReDim bytes(0 To bm.BMPWidthBytes - 1, 0 To hgt - 1)
    18.     GetBitmapBits picColor.Image, bm.BMPWidthBytes * bm.BMPHeight, bytes(0, 0)
    19.  
    20. ProgressBar1.Min = 0
    21. ProgressBar1.Max = hgt - 1
    22.     ' Convert the data to gray scale.
    23.     For Y = 0 To hgt - 1
    24.         For x = 0 To wid - 1 Step 3
    25.             ' Get the current pixel value.
    26.             red = bytes(x * 3, Y)
    27.             green = bytes(x * 3 + 1, Y)
    28.             blue = bytes(x * 3 + 2, Y)
    29.             While (red = 100) And (green = 195) And (blue = 155)
    30.             bytes(x * 3, Y) = 0
    31.             bytes(x * 3 + 1, Y) = 0
    32.             bytes(x * 3 + 2, Y) = 0
    33.             Wend
    34.             bytes(x * 3, Y) = 255
    35.             bytes(x * 3 + 1, Y) = 255
    36.             bytes(x * 3 + 2, Y) = 255
    37.             Next x
    38.             ProgressBar1.Value = Y
    39.         Next Y
    40.  
    41.     ' Set the new pixel values.
    42.     SetBitmapBits picColor.Image, _
    43.     bm.BMPWidthBytes * bm.BMPHeight, bytes(0, 0)
    44.     picColor.Picture = picColor.Image
    45.  
    46.  
    47. End Sub
    Last edited by Kirun; Jun 26th, 2002 at 02:59 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width