Ask Your Question

How to create an ROI (Region-Of-Interest or submat) from a contour?

asked 2016-04-19 19:17:26 -0500

Solace gravatar image

Given an image Mat, and a contour (which is a MatOfPoint) in it, how can I create a ROI (Region Of Interest)/submat?

I can see three interesting methods on docs of Mat,

Mat submat(int rowStart, int rowEnd, int colStart, int colEnd) Extracts a rectangular submatrix.

Mat submat(Range rowRange, Range colRange) Extracts a rectangular submatrix.

Mat submat(Rect roi) Extracts a rectangular submatrix.

  • Is there a way to find out rowStart, rowEnd, colStart and colEnd from the contour?


  • Is there a way to get rowRange and colRange from the contour?


  • Can I make a Rect from the contour?
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2016-04-19 19:47:49 -0500

Tetragramm gravatar image

updated 2016-04-20 08:43:08 -0500

You want the function Imgproc.boundingRect()

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2016-04-19 19:17:26 -0500

Seen: 995 times

Last updated: Apr 20 '16