What is the best way to find bounding box for binary mask?
I have a binary mask of an object and want to get its bounding rectangle. Function cv::boundingRect wants a vector of cv::Point, while I have a matrix.
I've written my own function, which reduces the binary mask with CV_REDUCE_MAX first to a column then to a row and finds leftmost and rightmost and topmost and bottommost non-zero elements.
The mask is strictly binary (0 and 1).
Is there any better way?
When don't you put some index of max_x and max_y when you create the mask?
Can you describe how you create the mask?
I don't create a mask, it is given to my code from outside. I don't know, how it is created. Probably, by hands.