[enter image description here][1]I'm working in project and i arrived to a step that i have to find the greatest rectangle inside a segmented object, i tried some algorithm in the website but it doesn't work some one have an idea can help me, THANKS. segmented object
Asked
Active
Viewed 327 times
-1
-
what is the greatest rectangle? biggest area? longest side? is your blob always shaped like that? present your failed attempts. aks our friend google, he knows all those algorithms for sure :) – Piglet Jan 03 '17 at 16:53
-
the greatest rectangle is a biggest rectangle that can be draw inside an object. as we can see in my question bellow "segmented object" and "how the rectangle should appear inside the object" – Nas Sim Jan 03 '17 at 17:07
-
I see "a" rectangle in an ellipse and and I see a blob that is similar to an ellipse. you tell me that the greatest rectangle is the biggest rectangle, which doesn't add any information. – Piglet Jan 03 '17 at 17:17
-
Could you please check the second image "how the rectangle should appear inside the object" i added to my question it clarify what i'm loocking for, thank you. – Nas Sim Jan 03 '17 at 17:24
-
yes and it shows an ellipse containing some rectangle. while you have something that looks more like a potatoe and ask for the greatest rectangle inside a segmented object. until now, even after having been asked 2 times, you have not specified what "greatest" means for you. So I can only assume that you want the largest area, but I could be wrong. Be precise in what you ask so people don't have to make assumptions... what about orientation? do you want to fit it into your potatoe or into an ellipse fitted into your potatoe? – Piglet Jan 03 '17 at 17:32
1 Answers
1
As you seem incapable of telling me/us if greatest rectangle means "the maximum area rectangle that fits into the white blob" I'll just assume it...
I further assume that you are looking for a rectangle which sides are parallel/perpendicular to the x/y axis.
Further I assume that you want to fit it into the irregular shaped blob in your image, not into an ellipse, closest to your potatoe...
Then with a few changes you can simply use the algorithm described here: Find largest rectangle containing only zeros in an N×N binary matrix
and on countless other sites google would provide you for "rectangle inside blob"
-
thank you for you answer, actually i'm worcking in a project for the classification of fruit (image processing for fruit images), i used some function to see if the image obtained are spherical or circular. for example for some of them i find this result: MajorAxisLength: 1.1929e+03 a MinorAxisLength: 1.1497e+03 an Accentricity: 0.2667 and an Orientation: 86.0743, for an other image MajorAxisLength: 1.7901e+03 a MinorAxisLength: 1.0651e+03 an Accentricity: 0.8037 and an Orientation: 88.0622. now i have to loock for the biggest possible rectangle in the area (segmented object) – Nas Sim Jan 05 '17 at 14:57
-
i tried this solution [link](http://stackoverflow.com/questions/30133895/how-can-i-detect-the-maximum-sized-rectangle-that-i-can-draw-onto-the-mask) but i get error "Index exceeds matrix dimensions." – Nas Sim Jan 05 '17 at 15:20