Need advice on processing steps

asked 2015-12-15 03:18:23 -0600

Hi all,

I'm very new to OpenCV and image processing in general so please excuse my ignorance. That said, I'm very excited about the possibilities and for the past 2 weeks have been trying to learn as much as I can.

I've got to the stage where I can build simple programs to load, process and save images. What I now need is some advice on the best way and/or steps to process my images.

My goal is to automatically analyse a photo book design to determine if the images on the page are correctly aligned. Ideally I'd like to be able to identify each image (always a rectangle) and calculate the corner points. From this, I should then be able to determine relative proximity and horizontal or vertical alignment. Hope that makes sense. I've attached an example source image.

I've been experimenting with thresholding and canny edge detection, but with limited results.

Any guidance on how to process the images so as to identify the 'image rectangles' would be great.

Thanks in advance.

image description

edit retag flag offensive close merge delete

Comments

You can do a threshold on 255 or 254, because your bg is white and then a findContour, then try to make them rectangles (using boundingRect). Now you have Rects, and their tl and br points, and you can compute the alignment

thdrksdfthmn gravatar imagethdrksdfthmn ( 2015-12-15 04:49:38 -0600 )edit

Thanks for the reply. What if an image contains pure white along an edge ... i.e. bleeds in to background. Is there a way to 'recognise' a rectangle even if an edge is broken? Does that make sense.

Thanks again

SRandall gravatar imageSRandall ( 2015-12-15 07:22:59 -0600 )edit

If for example your most right image has perfect white (255, 255, 255) in sky area, which is not the case, then your bounding rectangle (detected with boundingRect) will arrive till the "top-est" point on the building. On the other hand, if you have a bird on that sky, than it will be interpreted as a new rectangle. So IMHO you should verify that your images have the correct place when you are creating that grid of images

thdrksdfthmn gravatar imagethdrksdfthmn ( 2015-12-15 07:57:06 -0600 )edit

Did you take a look at cv::HoughLines or line segment detector

matman gravatar imagematman ( 2015-12-15 11:19:57 -0600 )edit

Thanks matman, will give that a try.

SRandall gravatar imageSRandall ( 2015-12-15 15:14:57 -0600 )edit

The lines are going to do the same thing as the findContours does in the case of same colour in picture like in background. Maybe the bird-case it's going to be eliminated, but you can filter the contours by area before verifying the grid...

thdrksdfthmn gravatar imagethdrksdfthmn ( 2015-12-16 02:16:01 -0600 )edit