user4834736
user4834736

Reputation: 29

Biggest Rectangle within one color

I struggle to find a solution to the following problem :

I used opencv to mark all connected white pixels with a unique label.

Now i got a group of those elements. Those objects often are 90% rectangular but most of the time contain some extra lines and stuff.

Im searching for a algorithm which does thr following :

-get biggest Rectangle out of image(within the same label) - fast performance -maybe even filter, larget rectangle which contains at least xx% Pixels with the same label

Maybe someone can help me Thanks a lot Edit: Example Pictures(in this case fo licence plate location): my desired output of the algorithm would be the rectangle of the plate(and of curse all other rectangles in the image, im gonna filter them later)

Important the rectangles may be rotated !

Marked some example rectangles red

enter image description here

Upvotes: 2

Views: 193

Answers (1)

user1196549
user1196549

Reputation:

My suggestion

  • make sure to fill small holes either by blob analysis or mathematical morphology;

  • compute the distance map in the white areas;

  • binarize the distance map with a threshold equal to the half plate height.

The rectangles will appear as line segments long as the plate width minus the plate height. You may locate them by fitting rotated rectangular bounding boxes; they must have a large aspect ratio.

Upvotes: 1

Related Questions