Need advice on processing steps
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.
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
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
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
Did you take a look at cv::HoughLines or line segment detector
Thanks matman, will give that a try.
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...