get RGB values

This is a discussion on get RGB values within the C++ Programming forums, part of the General Programming Boards category; Hi, At the moment I am currently programming code that should hopefully extract a registration plate from an image (it ...

  1. #1
    Registered User
    Join Date
    Mar 2005
    Posts
    1

    get RGB values

    Hi,

    At the moment I am currently programming code that should hopefully extract a registration plate from an image (it is read in as a Bitmap and is stored as JPEG). All extraction is from the bitmap image.

    I am having trouble with extracting the yellow colours (for the registration) from the image. It currently scans each pixel, but they are not stored in an array or anything.

    Is there anyone who knows how to extract yellow from an image using C++?? (I am using Borland v6).

    Thanks in advance

  2. #2
    DeX
    DeX is offline
    Infected Coder DeX's Avatar
    Join Date
    Sep 2004
    Location
    Cardiff, Wales
    Posts
    7
    Probably not the best way but you can use GetPixel to get the colour of a pixel in a specific DC.

  3. #3
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,831
    You are trying to write code that will enable you to get around the registration images people use to prevent script kiddies and other pests/parasites signing up for accounts?
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  4. #4
    Registered User
    Join Date
    Apr 2003
    Posts
    2,662
    Is it possible to read the rgb colors of another application that is running on your computer?

  5. #5
    DeX
    DeX is offline
    Infected Coder DeX's Avatar
    Join Date
    Sep 2004
    Location
    Cardiff, Wales
    Posts
    7
    Yes, of course. You just need to get the drawing context of the particular element you want to get the rgb values from. Or you can just take a screen shot of the entire screen and read them from that. Maybe I misunderstood your question 7stud.

    And I don't think this thread is about getting around those registration images. Even if it were it would be one thing to read a number plate off a clear image and another to read those registration images. Some of them totally screw around with the letters and I imagine it would be very very difficult to get a computer to read them.

  6. #6
    Hardware Engineer
    Join Date
    Sep 2001
    Posts
    1,398
    ...it is read in as a Bitmap and is stored as JPEG. All extraction is from the bitmap image.... but they are not stored in an array or anything.
    Hmmmm... A bitmap is an array. So, if your are converting it to JPEG, that's the wrong apporach.

    If your source of the image is the screen (not a file), then GetPixel is probably what you want.

    If you have a bitmap file, you should use that directly. A bitmap file is not simply an array, but is the "easiest" format. It has a header, and some optional non-lossy RLE compression.

    If you have a JPEG file, you'll need to convert it to a bitmap before any processing or analysis.

    If you're interested, you can find the file-format specifications for bitmap and JPEG at wotsit.org.

  7. #7
    Registered User
    Join Date
    Apr 2003
    Posts
    2,662
    Quote Originally Posted by DeX
    Yes, of course. You just need to get the drawing context of the particular element you want to get the rgb values from.
    How would you do that?

    Or you can just take a screen shot of the entire screen and read them from that. Maybe I misunderstood your question 7stud.
    Can an application obtain a screenshot?[/QUOTE]

  8. #8
    DeX
    DeX is offline
    Infected Coder DeX's Avatar
    Join Date
    Sep 2004
    Location
    Cardiff, Wales
    Posts
    7
    Yes you can.

    If you want to grab the drawing context of a particular portion of a particular application then you just need to use something like Spy++ to find the window title or the window class name of the particular window you want to grab. Then you can use the FindWindow or FindWindowEx functions to get the hWnd of the window you want to grab. Then you can just use GetDC to get the device context of that window. Then it's just a simple matter of BitBlting the device context onto your window or your own memory DC. Or you can just use GetPixel directly on the DC you get from GetDC.

    If you want to take a screenshot of the entire screen then you can use GetDC with the parameter 0 and it will return the device context of the entire screen. This lets you make a screen shot or draw directly onto the screen etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. OpenGL: Pixel addition
    By Hunter2 in forum Game Programming
    Replies: 4
    Last Post: 12-15-2008, 02:36 PM
  2. Get RGB values with second way
    By Leite33 in forum Windows Programming
    Replies: 3
    Last Post: 10-11-2006, 02:34 AM
  3. Need help with project
    By chrisa777 in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2006, 06:01 PM
  4. How to read out the RGB values of an image?
    By pjeremy in forum C Programming
    Replies: 5
    Last Post: 05-28-2006, 09:49 AM
  5. Stopwatch program (need help!)
    By modnar in forum C Programming
    Replies: 9
    Last Post: 03-22-2004, 12:42 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21