从照片中删除纸张纹理图案

发布于 2024-10-26 10:18:00 字数 322 浏览 3 评论 0 原文

我扫描了一张带有纸张纹理图案的旧照片,我想在不降低图像质量的情况下尽可能多地去除纹理。有没有办法,可能使用 MATLAB 中的图像处理工具箱?

我尝试应用 FFT 变换(使用 Photoshop 插件),但我不能找到任何要涂掉的清晰白点。对于这种方法来说,模式可能不太规则?

您可以看到下面的示例。如果您需要完整的图像,我可以将其上传到某个地方。 照片样本

I've scanned an old photo with paper texture pattern and I would like to remove the texture as much as possible without lowering the image quality. Is there a way, probably using Image Processing toolbox in MATLAB?

I've tried to apply FFT transformation (using Photoshop plugin), but I couldn't find any clear white spots to be paint over. Probably the pattern is not so regular for this method?

You can see the sample below. If you need the full image I can upload it somewhere.
photograph sample

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

蓝眸 2024-11-02 10:18:00

不幸的是,您几乎陷入了空间域,因为该模式的重复性不足以使傅立叶分析发挥作用。

正如@Jonas 和@michid 所指出的,过滤将帮助您解决这样的问题。通过过滤,您需要在要保留的细节量和要删除的噪声(或不需要的图像成分)量之间进行权衡。例如,@Jonas 使用的中值滤波器完全删除了纸张纹理(甚至是图像底部边缘附近的圆形划痕),但它也删除了眼睛、头发、脸部和背景内的所有纹理(尽管我们并没有真正删除它们)。非常关心背景,重要的是前景)。您还会看到图像对比度略有下降,这通常是不受欢迎的。这使图像具有人造的外观。

这是我处理这个问题的方法:

  • 检测纸张纹理图案:
    • 对图像应用高斯模糊(使用大内核以确保所有纸张纹理信息被破坏
    • 计算模糊图像和原始图像之间的图像差异
    • 编辑 2 对差异图像应用高斯模糊(使用小型 3x3 内核)
  • 值处理,这会生成可用作掩模的二值图像。
  • 使用经验确定的阈值对上述模式进行阈 与纸张图案相对应的图像部分

纸张纹理图案(阈值处理之前):

在此处输入图像描述

您想要作为上图中几乎没有实际的图像信息,您会发现您可以非常微弱地辨认出脸部的边缘(这不好,但这是我有时间的最好的)。纹理图像尽可能均匀(以便阈值处理在整个图像上给出相同的结果)。同样,上图的右侧稍暗,这意味着对其进行阈值处理会很困难。

最终图像:

在此处输入图像描述

结果并不完美,但它已完全删除了高度可见的纸张纹理图案同时比更简单的过滤方法保留更多的高频内容。

编辑

填充区域通常是纯色的,因此如果您仔细观察图像,会显得有点突出。您还可以尝试向填充区域添加一些低强度零均值高斯噪声,使它们看起来更真实。您必须选择噪声方差以匹配背景。根据经验确定它可能就足够了。

这是添加了噪声的处理后的图像:

在此处输入图像描述

请注意,去除纸样的部分比较困难因为添加的高斯噪声掩盖了它们。我对整个图像使用了相同的高斯分布,但如果你想更复杂,你可以对面部、背景等使用不同的分布。

Unfortunately, you're pretty much stuck in the spatial domain, as the pattern isn't really repetitive enough for Fourier analysis to be of use.

As @Jonas and @michid have pointed out, filtering will help you with a problem like this. With filtering, you face a trade-off between the amount of detail you want to keep and the amount of noise (or unwanted image components) you want to remove. For example, the median filter used by @Jonas removes the paper texture completely (even the round scratch near the bottom edge of the image) but it also removes all texture within the eyes, hair, face and background (although we don't really care about the background so much, it's the foreground that matters). You'll also see a slight decrease in image contrast, which is usually undesirable. This gives the image an artificial look.

Here's how I would handle this problem:

  • Detect the paper texture pattern:
    • Apply Gaussian blur to the image (use a large kernel to make sure that all the paper texture information is destroyed
    • Calculate the image difference between the blurred and original images
    • EDIT 2 Apply Gaussian blur to the difference image (use a small 3x3 kernel)
  • Threshold the above pattern using an empirically-determined threshold. This yields a binary image that can be used as a mask.
  • Use median filtering (as mentioned by @Jonas) to replace only the parts of the image that correspond to the paper pattern.

Paper texture pattern (before thresholding):

enter image description here

You want as little actual image information to be present in the above image. You'll see that you can very faintly make out the edge of the face (this isn't good, but it's the best I have time for). You also want this paper texture image to be as even as possible (so that thresholding gives equal results across the image). Again, the right hand side of the image above is slightly darker, meaning that thresholding it well will be difficult.

Final image:

enter image description here

The result isn't perfect, but it has completely removed the highly-visible paper texture pattern while preserving more high-frequency content than the simpler filtering approaches.

EDIT

The filled-in areas are typically plain-colored and thus stand out a bit if you look at the image very closely. You could also try adding some low-strength zero-mean Gaussian noise to the filled-in areas to make them look more realistic. You'd have to pick the noise variance to match the background. Determining it empirically may be good enough.

Here's the processed image with the noise added:

enter image description here

Note that the parts where the paper pattern was removed are more difficult to see because the added Gaussian noise is masking them. I used the same Gaussian distribution for the entire image but if you want to be more sophisticated you can use different distributions for the face, background, etc.

贱贱哒 2024-11-02 10:18:00

中值滤波器可以帮助您一点:

img = imread('https://i.sstatic.net/JzJMS.jpg');
%# convert rgb to grayscale
img = rgb2gray(img);
%# apply median filter
fimg = medfilt2(img,[15 15]);
%# show
imshow(fimg,[])

在此处输入图像描述

请注意,您可能需要先填充图像以避免边缘影响。

编辑:比[15 15]更小的过滤器内核将更好地保留图像纹理,但会留下更多可见的过滤痕迹。

A median filter can help you a bit:

img = imread('https://i.sstatic.net/JzJMS.jpg');
%# convert rgb to grayscale
img = rgb2gray(img);
%# apply median filter
fimg = medfilt2(img,[15 15]);
%# show
imshow(fimg,[])

enter image description here

Note that you may want to pad the image first to avoid edge effects.

EDIT: A smaller filter kernel than [15 15] will preserve image texture better, but will leave more visible traces of the filtering.

守护在此方 2024-11-02 10:18:00

好吧,我尝试了一种使用各向异性扩散的不同方法,使用在更广泛区域上运行的第二个系数

这是我得到的输出:

在此处输入图像描述

Well i have tried out a different approach using Anisotropc diffusion using the 2nd coefficient that operates on wider areas

Here is the output i got:

enter image description here

旧人哭 2024-11-02 10:18:00

从图片中可以看出,与图像本身相比,噪声的频率相对较高。因此,应用低通滤波器应该可行。查看功率谱 abs(fft(...)) 以确定截止频率。

From what i can See from the Picture, the Noise has a relatively high Frequency Compared to the image itself. So applying a low Pass filter should work. Have a look at the Power spectrum abs(fft(...)) to determine the cutoff Frequency.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文