我正在尝试在图像上使用平滑/模糊滤镜,但仅在源的特定路径/区域中使用。 (目前使用openCV)
怎么办呢?
现在我正在做类似
的事情cv::GaussianBlur(im, newim, cv::Size(5,5),1.5);
但我想做
cv::GaussianBlur(im, newim, cv::Size(5,5),1.5,MyClosedPath);
如果更容易,我也可以使用任何ios类。 (还没有找到办法)
答案 0 :(得分:4)
您可以从原始矩阵中获取子矩阵,例如:
cv::Mat subMat = originalMatrix(cv::Rect(x, y, width, height));
其中x,y,width,height是子图像的位置。 然后在子矩阵上执行高斯模糊。
[编辑] 如果你想模糊复杂的形状,一种方法是模糊整个图像,然后使用mat.copyTo和模糊部分的面具:
cv::Mat mask = ?; // this should be a CV_8U image with 0 pixels everywhere but where you want to blur the original image
cv::Mat blurred;
cv::gaussianBlur(image, blurred, cv::Size(5,5),1.5);
cv::Mat output = image.clone();
blurred.copyTo(output, mask);