Search code examples
algorithmgraphicsgeometrybounding-box

How to determine bounding rectangles of multiple elements?


I would like to implement an algorithm which will find the bounding rectangles of contours (already determined by another algorithm). The only thing I have is a binarized image (as shown below). The basic idea would be to :

  • take something like this - a preprocessed binarized image enter image description here

  • and produce something like this enter image description here


Solution

  • Check out connected component labeling: http://en.wikipedia.org/wiki/Connected-component_labeling . You can either find connected components of white pixels or black pixels in this case (White is computationally easier since you have fewer white points in the image).