【问题标题】:smoothing in a particular area of image [duplicate]在图像的特定区域进行平滑[重复]
【发布时间】:2012-10-08 12:35:16
【问题描述】:

可能重复:
How to set ROI in OpenCV?

我正在尝试在图像上使用平滑/模糊滤镜,但仅限于源的特定路径/区域。 (目前使用openCV)

如何做到这一点?

现在我正在做类似的事情

cv::GaussianBlur(im, newim, cv::Size(5,5),1.5);

但我想这样做

cv::GaussianBlur(im, newim, cv::Size(5,5),1.5,MyClosedPath);

如果更容易,我也可以使用任何 ios 类。 (还没有找到方法)

【问题讨论】:

  • 设置一个ROI(Region of Interest),然后将其复制到另一个Mat,平滑,再复制回原来的Mat。

标签: objective-c ios image-processing opencv


【解决方案1】:

您可以从原始矩阵中获取子矩阵,例如:

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);

【讨论】:

  • 我需要做一些更复杂的形状(和“孔”)——我如何将它们组合回一个图像?
  • 对子矩阵所做的任何更改也会应用于您的原始矩阵。我将为您的第二个问题编辑我的答案
  • 通过标记告诉我是否回答了您的问题!谢谢
猜你喜欢
  • 1970-01-01
  • 2017-08-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多