Image/Rectangle matching
4 views (last 30 days)
Show older comments
Hi
I have a two image in which there is a fixed size rectangle on base image and I wanted to compare that rectangle with second scanned image.
I don’t know the position of rectangle in second image it might be skewd, scale or even tiled.
Does matlab has any function to compare rectangles and automatically scaled or deskew the second rectangle based on reference rectangle?
please help me out thanking you;
0 Comments
Accepted Answer
David Young
on 14 Jun 2011
The question boils down to: "How can I find a rectangle in an image?" Once you have found the coordinates of the corners of the rectangles in the images, it is easy to find the transformation that maps one to the other, and apply it to one of the images.
How hard finding the rectangle is depends on what else is present in the image. It's hard to advise without knowing this. However, one approach worth exploring might be to use the Hough transform to find straight lines, and look for groups of these that satisfy some geometric conditions. The Hough transform is available in the Image Processing Toolbox.
5 Comments
David Young
on 15 Jun 2011
Thanks - it's easier to understand the problem now. I see that the rectangles are clearly visible.
My recent suggestion in a comment above, of using affine optic flow matching, is not a good idea - you can forget that one.
My original proposal, to use edge detection followed by the Hough transform, followed by finding the intersections of the most prominent lines, might work. Once you've found the rectangle corners in the two images, you can use maketform and imtransform to align the images.
However, as the rectangles are very dark and have thick boundaries, it might be simpler to find them by thresholding, and then using regionprops to (a) find the largest region and (b) find its extrema. It may even be that the extrema of the region will give you adequate corner coordinates. I would try this approach first, before going to the Hough transform, as it is simpler.
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!