# Creating rectangles from “ImageCorners” output

I want to create multiple rectangle areas from this image

where the rectangle would be defined by the points on the edges of the outer most squares - dont mind the inner ones. In the end there would be 45 rectangle areas. I would then like to perform some tests whether there are certain spots of interest within the newly defined square areas (probably with a test if a point is in the convex area ) but lets leave that part for now.

My code now looks something like this:

img="the 45 squares ime in the provided link"
imgcorner = ImageCorners[img, MaxFeatures -> (45*4)];
HighlightImage[img, imgcorner ]


I get points on the corners of the squares in the given image, but my problem is in the fact that ImageCorners gives the output is ranked by decreasing measure of corner strength and I don't know how to organize the data in a more meaningful way.

• Take a look at MorphologicalComponents[ ] and ComponentMeasurements[ ]. Much easier to go from those – Dr. belisarius Nov 9 '15 at 22:16
• boxes = image // Binarize // ColorNegate // ComponentMeasurements[#, "BoundingBox"][[All, 2]] & followed by Graphics[{FaceForm[], EdgeForm[Black], Rectangle @@@ boxes}] to verify the result. – Stephen Luttrell Nov 9 '15 at 23:34