views:

132

answers:

1

I am new on OpenCV and DIP, currently I need find a rectangle region from a low-quality picture which has only rectangle areas beyond the background.

I used canny detector to get out many many tiny edges, which composes several rectangle regions, and some other separate noise-alike edges.

So, experts, how can I process on this middle-output image to locate the position of those meaningful rectangle region?

Thanks a lot!

A: 

The obvious thing to do first is discarding any edges that don't belong to a rectangle. The best case is if your rectangles are all oriented the same direction as the camera. In that case, discard any edge that's not North-South or East-West. If the rectangles all have the same orientation, but the camera doesn't, find the dominant direction module 90 degrees, and discard any outlier edges. The worst case is when the rectangles all have different orientations. In that case, you'd still expect edge direcions to cluster: for every edge, there should be at least one parallel and two orthogonal edges. Discard any unmatched edge. (This assumes you find edges more than a few pixels long; it's hard to deterimine the angle of shorter edges.)

After you've eliminated spurious edges by direction, the next step is to see whether you can connect them. You should still have them grouped by angle from the previous step. Now, assume that edges which are aligned belong to the same rectangle, and replace them with a single longer edge. This may cause fake edges between aligned rectangles. This is probably not a major problem, but if it is, fix it with a validation step at the end.

It's likely your edge finder will not work well near corners, because the real edge changes direction abruptly there. Hence, you should extend the edges you've found by a few pixels.

The extended edges will now produce a whole bunch of crossings. Again, take advantage of the fact that you've ordered your edges by direction. Just check for crossings of almost-orthogonal edges. If you find them, create a "crossing" object and associate it with the two edges. They're the tentative corners.

Once you've doe this, look for edges which have at least 2 crossings and see if you can match them up. Depending on the quality of your data, you may want to decide you've found a rectangle when you have 3 or 4 corners. If you find too many crossings on a single edge, you might have connected the edges of two aligned rectangles. This can be especially hard if you have rectangles that are aligned on both sides:

 _ _
|_|_|
MSalters
Tons of thanks! maybe this' not directly related to my problem, my fault that it's not clearly asked there. but your information is very helpful to clear my mind on this sort of problem.I updated this question with a input original image as http://picasaweb.google.com/smileweaver/Open#5412724590622419906 ; my task is to find those golden-yellow strip/rectangle. I was thinking to find them by the canny-edged mid-output image as http://picasaweb.google.com/smileweaver/Open#5412726055392715858 , in this picture, redlines is of houghlined.Could you guys keep on helping out of this problem?
smilewa