Get Grayscale Value of grayscale image (RGB)
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 2 of 2

Thread: Get Grayscale Value of grayscale image (RGB)

  1. #1
    Join Date
    Jan 2013

    Get Grayscale Value of grayscale image (RGB)

    I'm making simple application for image recognition using grayscale image format. The problem is how to get the value of a grayscale image. Its value is RGB or pixel. Then the value will be used as a comparison between the sample images with the image to be recognized.

    I have a sample program but can not use this code to, because the code for vb.6. Can someone help me convert this code to Or do you have another solution?

    I was more expecting another solution to this problem in code.

    Thank you very much
    For Y = 1 to Picture1.scaleheight
    For x = 1 to Picture1.ScaleWidht
    p = Get pixel (picture1.hdc, X,Y)
    r= p and &HFF
    g = (p\&H100)and &HFF
    b = (p\&H10000)and &HFF
    grtotr=grtotr + r
    grratr = Round(gtotr/(picture1.ScaleHeight*Picture1.Scalewidht),2)
    grtotg=grtotg + g
    grratg = Round(gtotg/(picture1.ScaleHeight*Picture1.Scalewidht),2)
    grtotb=grtotb + b
    grratb = Round(gtotb/(picture1.ScaleHeight*Picture1.Scalewidht),2)
    ' the result of the calculation transferred to textbox
    Text1.text = grratr ' R value
    Text2.text = ggratg 'G value
    Text3.text = ggratb ' B value

  2. #2
    Join Date
    Jul 2001
    Sunny South Africa

    Re: Get Grayscale Value of grayscale image (RGB)

Posting Permissions

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

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

This is a survey!

HTML5 Development Center