Search code examples
c++opencvimage-processingfiltering

How to perform OpenCV boxFilter for a ROI?


I have an image and I want to perform OpenCV boxFilter on a ROI of this image.

image = cv::imread(argv[1], CV_LOAD_IMAGE_COLOR);   
cv::Rect roi( 10, 10, 64, 64);
cv::Mat output;
cv::boxFilter(image(roi),output,-1,cv::Size(scale_size,scale_size));

I want to know what happen if the kernel is out of the ROI? Use the pixels out of the ROI but still within the image to do the filtering or just use the value specified by the BorderType?

Actually I want to use the former to do the filtering.


Solution

  • ... the answer is actually incorrect (will be deleted when it is un-accepted) ...