Search code examples
c++imageopencvmaskblur

Blurring non-rectangular region of an image, then downsample whole image - OpenCV


I am using OpenCV3 to blur and downsample an image, I just want to blur the region inside the area defined by a binary mask like:

enter image description here

After that region is blurred, I would like to downsample the image without blurring the whole image again, so pyrDown is not useful for me.

Any idea?


Solution

  • Tricky way:

    cv::Mat roi;
    cv::blur(image & mask,roi,cv::Size(3,3));//Or whatever blurring you want
    cv::Mat Result=(image & (~mask)) + roi;
    cv::resize(result,result,cv::Size(New_Width,New_height)); // Or whatever downsampling you want