Skip to content Skip to sidebar Skip to footer

How To Blur A Rectagle With Opencv

Is there any way to blur a Mat object in OpenCv (for Android) so that the blur is contained within a Rect object? I am doing a face blurring application and have tried this: Mat ma

Solution 1:

Ok I figured out how to do it:

Matmask= blurred.submat(rect);
Imgproc.GaussianBlur(mask, mask, newSize(55, 55), 55); // or any other processing

Then blurred will have the blurred region. This is because submat doesn't copy the data in blurred, but rather references it, so when the blur is applied it only blurs the parts in blurred referenced by mask.

Solution 2:

I'm not an expert but I think you are applying a filter with k size so actually k x k pixels with k odd (3x3, 5x5 etc). When you try to position yourself in the (0,0) the bound of the filter excees, because the filter maps it's center in the (0,0) pixel. If you k is 3 for example you need to start in the (2,2). And if you want a gaussian bidimensional filter remember to apply it one time in the x direction and one time in the y direction instead one time in the (x.y). This is for a performance reason.

Post a Comment for "How To Blur A Rectagle With Opencv"