【问题标题】:Denoise this image of a coin, removing periodic noisy lines去噪这个硬币图像,去除周期性的噪声线
【发布时间】:2021-09-05 09:16:33
【问题描述】:

我有一张 360x360 图像,我想删除其中的线条

它上面的部分有我正在使用 MATLAB 的周期性噪声线 我尝试了中值滤波器,但没有工作如何对此图像进行去噪和去除线条?

我试过了

%image 360x360
[rows, columns, numberOfColorChannels] = size(image);
subplot(2, 2, 1);
imshow(image,[]);
horizontalProfile = mean(image);
subplot(2, 2, [2, 4]);
plot(horizontalProfile, 'b-');
grid on;

bottomEnvelope = movmin(horizontalProfile, 10);
upperEnvelope = movmax(horizontalProfile, 10);
deltaGL = mean(upperEnvelope- bottomEnvelope)

hold on;
plot(bottomEnvelope, 'r-', 'LineWidth', 2);
plot(upperEnvelope, 'r-', 'LineWidth', 2);
% Compute midline
midline = (bottomEnvelope + upperEnvelope) / 2;
plot(midline, 'm-', 'LineWidth', 2);
columnsToDim = horizontalProfile > midline;
image(:, columnsToDim) = image(:, columnsToDim) - deltaGL;
subplot(2, 2, 3);
imshow(image, []);

但这并没有更好的工作

我已经把图片数据上传到Google Drive

【问题讨论】:

  • 您不太可能得到答案的主要原因是因为您要求的是图像处理算法专业知识,而不是代码问题。但你可能很幸运,谁知道呢!
  • 你会碰巧有这张图片的灰度版本吗?看起来你有一个相当嘈杂的二进制版本 - 并且可能难以清理。以我有限的经验,这是问题空间中人为的复杂性,可以通过使用管道中更高层的图像表示来简单地解决。
  • @Rohitgupta 这里是similar question,唯一的区别是那里的噪音是垂直的!

标签: matlab image-processing noise


【解决方案1】:

这是Fast Fourier Transform (FFT) 的完美用例。

FFT 将空间域中的图像转换为其频域。通过去除相应的高频信号,频域可用于平滑空间域中的特定噪声(在您的情况下为垂直线)。您可以通过大量来源了解它,因此我将这部分留给您。

这是我的方法。*

import cv2
import numpy as np
import matplotlib.pyplot as plt

img = cv2.imread('coin.png',0)

# get the frequency domain
f = np.fft.fft2(img)
fshift = np.fft.fftshift(f)
magnitude_spectrum = 20*np.log(np.abs(fshift))


# smoothen the vertical lines in the spatial domain =
# remove the high frequency signals (i.e. horizontal lines) in the frequency domain 
rows, cols = img.shape
crow,ccol = rows//2 , cols//2
fshift[crow-5:crow+6, 0:ccol-10] = 0
fshift[crow-5:crow+6, ccol+11:] = 0
magnitude_spectrum_no_vertical = 20*np.log(np.abs(fshift))


# get the spatial domain back
f_ishift = np.fft.ifftshift(fshift)
img_back = np.fft.ifft2(f_ishift)
img_back = np.real(img_back)

这只是输出图像。

随意尝试不同的方法:在 FFT 之前应用高斯滤波器以改善结果、屏蔽背景等。

*:抱歉,我没有 MATLAB。不过,将我的 Python 脚本移植到 MATLAB 应该很容易。

【讨论】:

    猜你喜欢
    • 2017-02-27
    • 1970-01-01
    • 2017-07-05
    • 1970-01-01
    • 2023-04-05
    • 2014-05-22
    • 2016-03-05
    • 2021-08-16
    • 1970-01-01
    相关资源
    最近更新 更多