Image processing

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • engaya
    New Member
    • Feb 2012
    • 2

    #1

    Image processing

    I've got a black background picture drawn inside a white box
    How to detect the white box and print it in picture box
    Attached Files
  • GaryTexmo
    Recognized Expert Top Contributor
    • Jul 2009
    • 1501

    #2
    I'm sorry, I'm a little confused about what you want to do. Are you asking how to find the white rectangle within the black one?

    If so, this image analysis is pretty non-trivial... probably beyond of "help boards" like bytes, as it's not our job to write our code for you ;) That said, I think an exact rectangle detection algorithm shouldn't be too hard... at least an inefficient one.

    Perhaps you could start scanning your image, knowing the background is one colour (ie, black). Search each pixel on each line until you find the foreground colour (ie, white). Once you have, note the position of the top-left corner. From there, scan right until you stop encountering the foreground and hit the background. This will be your top-right corner. From the top left and top right corners, search down until you find the background colour again. Now you've got the bottom left and right corners respectively and can build a rectangle from that. You may wish to examine the volume of your rectangle to see if there are any other coloured pixels in it... this will tell you if it's not a real rectangle shape. Also, make sure you account for the cases where the white rectangle is aligned with the edge of the image so you don't try to access an out of bounds index.

    That should work as a fairly basic algorithm... I think. I've frankly never tried it... but give it a shot and let me know how it works out :)

    Comment

    • engaya
      New Member
      • Feb 2012
      • 2

      #3
      Thanks for the reply

      I know algorithm well and have already been scanning each pixel but my problem in artificial intelligence
      not need your code

      Comment

      • GaryTexmo
        Recognized Expert Top Contributor
        • Jul 2009
        • 1501

        #4
        I... don't know what you're asking here...

        Comment

        Working...