Region Detection

This is a discussion on Region Detection within the C++ Programming forums, part of the General Programming Boards category; I have a greyscale image, with a white background (not perfect white, more a mixed cream), and images on it, ...

  1. #1
    Registered User
    Join Date
    Oct 2003
    Posts
    6

    Region Detection

    I have a greyscale image, with a white background (not perfect white, more a mixed cream), and images on it, which are surrounded by a white border, then a black border (can be any thickness).

    I need to be able to detect and highlight the images on this background. The image is in raw format, I can load an display it, and store it in "image[][]".

    Please, any ideas?!!!

  2. #2
    Banned nickname_changed's Avatar
    Join Date
    Feb 2003
    Location
    Australia
    Posts
    986
    Then created a nested loop so you loop through every value of image[x][y], and if the colour is not white or almost white, highlight it my.. making it darker?

  3. #3
    Registered User
    Join Date
    Oct 2003
    Posts
    6
    Thanks, but I have tried a similar method, and it messes up because the image goes "white background", "black border", then "white border", then picture. (I.e. -- Pictures have a black and white border).

    I am trying a few variations on this method, however, so thanks again!


    (Btw, sorry if my explanation of the problem is rubbish, please ask if there is anything needing clarification)

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,333
    This isn't your average newbie C++ question
    How about here for an overview of the problem
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  5. #5
    Registered User
    Join Date
    Oct 2003
    Posts
    6
    Indeed, and thanks for the links, I feel I am getting there now.

  6. #6
    Hardware Engineer
    Join Date
    Sep 2001
    Posts
    1,398

    Hmmm...

    It sounds like the borders are well-defined, and I assume that the borders are rectangular. So you probably should scan for the borders first. (Assuming that you don't already know where the borders are.)

    Once you know the coordinates for the borders, you can manipulate the pixels inside the borders.

  7. #7
    Registered User
    Join Date
    Jan 2004
    Posts
    37
    I think you have to first determine what will be the cut-off point for dark verses light. What level grayscale is it: 4, 16, 256 colors?
    Once you draw the line in the sand as to what is dark and what is light then you can start your analysis. I suggest that you take an average of the darkness of the pixels around a pixel so that you can get a true sense of the darkness of the pixel.

    Example:

    Say that there is 4 color grayscale with 0 being black and 3 being white. The following is 3x3 section of pixels from the whole image.

    3|2|2
    -------
    2|1|3
    -------
    2|1|1

    Say you want to determine if the pixel in the middle is light or dark. Well, it is 0 so it is dark but if you average the values of all the pixels in the region you will find that it is lighter than darker. If you were to look at the picture, this area would probably look like a lighter spot rather than a darker spot.

    Keep in mind that image recognition is mostly about finding edges and this is best done with averages of regions rather than on a pixel by pixel basis.

    This is only a small piece of the total solution, but I hope you can employ this to create a more fault tolerant algorithm.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Copy region of bitmap to region of rectangle
    By Sfpiano in forum Windows Programming
    Replies: 2
    Last Post: 08-18-2007, 11:58 AM
  2. Collision Detection
    By Grantyt3 in forum C++ Programming
    Replies: 3
    Last Post: 09-30-2005, 03:21 PM
  3. bounding box collision detection
    By DavidP in forum Game Programming
    Replies: 7
    Last Post: 07-07-2002, 11:43 PM
  4. collision detection
    By DavidP in forum Game Programming
    Replies: 2
    Last Post: 05-11-2002, 01:31 PM
  5. Replies: 4
    Last Post: 05-03-2002, 09:40 PM

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