Is there any algorithm to find the locations of rectangles in an image?
6 次查看(过去 30 天)
显示 更早的评论
Hi
I have two images - on both the images i have some(same in both) nos of small rectangles.
I call one image to be base image and other to be row image(scanned).now i have the rectangles locations on the base image(used as a template) i want those rectangles locations on the row image (that is variable) means,
The row image might be skewed,waved or tiled. is there any algorithm available in MATLAB that can help me to find the rectangles on an image.
Please help me..
Thanking You
0 个评论
采纳的回答
Image Analyst
2012-7-25
This could range anywhere from simple to complicated depending on how bad the image is. For example, are the rectangles all in the same position (roughly)? Are they all square? Are all images at the same magnification? Is there noise? How much can it be tilted? Do you ever expect any of the squares to be missing totally, like it's translated so much they're out of the picture? And so on. You probably gave the easiest example. To give a robust answer, you'd also have to upload the worst example too. For the example you gave, I'd just create a mask with holes in it at roughly the locations of where the squares are expected to be. Then multiply the mask by the image, threshold, label, and call regionprops. It can get more complicates. For example, you may have to locate the large black boundary, get its convex hull, then construct the mask, find the squares, see if they are all there, if they're not all there, try to find the circles and see if they are all inside the image or if any of them are missing. Etc.
3 个评论
Image Analyst
2012-7-25
I'd use thresholding and size filtering like I demonstrate in my BlobsDemo ( http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862) to get just the little squares. Then I'm use imtransform() to warp the image back into shape.
更多回答(1 个)
Sriram
2012-7-25
Your question has to be in more clearer way! Up to my understanding - (Aim) You are trying to figure out the rectangles from a image - what you tried is using a template or pattern match with a known image!!. I don think so you need to go for correlation!
I would suggest you to use "regionprops" -which can measure the properties of image regions
2 个评论
Sriram
2012-7-25
As you said regionprops doesn't gives the exact location. Using the below function after creating a template of the rectangular box, the position could be find !
normxcorr2 (template,original image)
the position of the rectangle which you required is found to be [34,31]
And are you going to use the same format/kind of OMR sheet ? If so check manually for the position in mm and based on the image size you can calibrate mm in pixels - allowing - automatically mark the position for different image provided the same format of OMR sheet is used! This would be the simplest way n will work better too !
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Segmentation and Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!