Ask Your Question

Performing Filter in a specific part of the image

asked 2017-06-06 07:38:53 -0500

arqam gravatar image

updated 2017-06-07 00:40:57 -0500

berak gravatar image

The defined method for filters example binary filter takes two parameters, the source image MAT and destination image MAT and performs filter on the full image.

But what if I want to perform operations like filter in only a part of the image for which we have the contour points (either Point or MatOfPoint).

The solution that I am looking for is in JAVA.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2017-06-07 00:38:23 -0500

berak gravatar image

updated 2017-06-07 00:40:18 -0500

if you have a Rect, e.g. from Imgproc.boundingBox() you can can use submat:

Mat roi = image.submat(rect);

operations, which don't change the depth or type of the image, can be done in-place:


else you need a new Mat for the output:

Mat gray = new Mat();
Imgproc.cvtColor(roi, gray, COLOR_BGR2GRAY);
edit flag offensive delete link more

Question Tools

1 follower


Asked: 2017-06-06 07:38:53 -0500

Seen: 140 times

Last updated: Jun 07 '17