Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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?

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?

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?