Is there any algorithm to find the locations of rectangles in an image?

6 visualizzazioni (ultimi 30 giorni)
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

Risposta accettata

Image Analyst
Image Analyst il 25 Lug 2012
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 Commenti
meghna bhatt
meghna bhatt il 25 Lug 2012
Modificato: meghna bhatt il 25 Lug 2012
ok i am sending the worst case image..
There is possibility of noise in the image.. no i dont expect any of the squares to be missing totally..
Image Analyst
Image Analyst il 25 Lug 2012
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.

Accedi per commentare.

Più risposte (1)

Sriram
Sriram il 25 Lug 2012
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 Commenti
meghna bhatt
meghna bhatt il 25 Lug 2012
Hi Sriram ,
Thanks for your response..:>
Let me make it more clearer as you have suggested
My Aim is to find exact locations of rectangle shapes (say image has 5 small rectangles then it should give me the 5 - x & y co-ordinates pairs) in an image,its ok if i dont use the base or reference image.
yes i have tried using pattern matching and also regionprops but its not able to give me the exact locations of rectangles in an image rather they are giving me the redundant points.
I am sending you the image in which i want rectangles for your reference to get it more clearer.
Sriram
Sriram il 25 Lug 2012
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 !

Accedi per commentare.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by