刹那的菜鸟

博客园 首页 新随笔 联系 管理

CvInvoke.Inpaint(img, mask, img, 10, InpaintType.Telea);

要注意各个参数。
创建掩码:

使用 CvInvoke.Rectangle 方法在掩码上标记水印位置,确保水印区域为白色(255),其他区域为黑色(0)。
修复图像:

使用 CvInvoke.Inpaint 方法修复图像,inpaintRadius 设置为一个合理的正值(例如 3),以便修复算法能够使用周围的像素信息来填充修复区域。

Mat mask = new Mat(img.Size, DepthType.Cv8U, 1);
mask.SetTo(new MCvScalar(0)); // 其他区域为黑色
CvInvoke.Rectangle(mask, matchRect, new MCvScalar(255), -1); // 水印区域为白色

// Debug: Save the mask to check the mask region
mask.Save(Path.Combine(processedDirectory, "mask_" + fileName));

posted on 2024-06-04 17:57  刹那的菜鸟  阅读(3)  评论(0编辑  收藏  举报