I want to find the largest inscribed square in single color image, which could be consists of discontinuous same color areas, for example below:
and then I have to find the largest inscribed blue square area
for this discontinues same color i must find the largest inscribed blue square area
now the current solution is "Maximum size square sub-matrix with all 1s"
First convert the picture to grayscale,and then convert matrix with 0 and 1, and calculate the largest square sub-matrix with all 1s,so we get the square region [left,top,size,size],for example, the first pink color photo 200x200, and then we get the blue square area [50,80,110,110]
as you can see, we can get the pixel range of largest inscribed square, But we get integer units. If the picture is small, we still get integer pixels, and the accuracy is definitely not enough, I want to know if there is a way to figure out the float point area,for example
Suppose the picture size is 10x10
and then we can calculate the largest inscribed square below [2.56, 2.78, 3.25,3.25]:
if the picture is smaller, the float area is very useful,for example, if the inscribed square only have two unit, and the left and top begin is not start with integer, so we lost one unit accurate. if i want to put some text into the inscribed square, for example:
and then the position of the text which is locate in inscribed square is not precise enough!
I have been struggling with this issue for months,I tried opencv but there is no solution or function to meet my requirements And I know there must be good solution to solve this problem,but I have no idea! I don't know how to solve it, please help me, appreciate any prompt or tips
Also, I would like to add more information about my problem:
<svg id="_0110068" data-name="0110068" xmlns="http://www.w3.org/2000/svg" width="500" height="500" viewBox="0 0 500 500">
<path id="439.97_240.36_3.84_3.84" d="M435.9652,238.4672c.262,5.3118,7.7188,9.656,13.8857,8.1239C446.2334,242.0454,442.6965,237.6206,435.9652,238.4672Z" style="fill: #80d1c0"/>
</svg>
you can copy the svg and put it into this website and press Draw then You can see a green block in the lower right corner
as you can seen, the
d = "M435.9652...Z" can be convert to picture, and the rect="439.97_240.36_3.84_3.84" is the largest inscribed square, that means left = 439.97, top = 240.36 , right = left + 3.84, bottom = top + 3.84, so the size is 3.84 of the largest inscribed square, you can't omitted 0.84 that is very important! but how can i get the float point area