【问题标题】:Using a clear portion of a picture to recreate a PSF使用图片的清晰部分重新创建 PSF
【发布时间】:2015-06-01 01:16:46
【问题描述】:

我正在尝试去模糊下图的模糊部分。

原来的PSF没有给出,所以我开始分析模糊的部分,看看是否有一个我可以大致辨认的单词。我发现我可以在模糊部分中辨认出“of”。如下所示,我在清晰部分中裁剪了模糊的“of”及其对应部分。

然后我通过 FFT 的讲座想到,您将模糊的(频域)除以特定的模糊函数(频域)来重新创建原始图像。

我想如果我可以做 Unblurred(频域)\Blurred(频域),就可以检索到原始的 PSF。请告诉我如何做到这一点。

下面是我的代码:

img = im2double(imread('C:\Users\adhil\Desktop\matlab pics\image1.JPG'));
Blurred = imcrop(img,[205 541 13 12]);
Unblurred = imcrop(img,[39 140 13 12]);

UB = fftshift(Unblurred);
UB = fft2(UB); 
UB = ifftshift(UB); 

F_1a = zeros(size(B));
for idx = 1 : size(Blurred, 3)
    B = fftshift(Blurred(:,:,idx));
    B = fft2(B); 
    B = ifftshift(B);

    UBa = UB(:,:,idx);
    tmp = UBa ./ B; 
    tmp = ifftshift(tmp); 
    tmp = ifft2(tmp); 
    tmp = fftshift(tmp); 
    [J, P] = deconvblind(Blurred,tmp);    

end

subplot(1,3,1);imshow(Blurred);title('Blurred');
subplot(1,3,2);imshow(Unblurred);title('Original Unblurred');
subplot(1,3,3);imshow(J);title('Attempt at unblurring');

但是,此代码不起作用,我收到以下错误:

Error using deconvblind
Expected input number 2, INITPSF, to be real.

Error in deconvblind>parse_inputs (line 258)
validateattributes(P{1},{'uint8' 'uint16' 'double' 'int16' 'single'},...

Error in deconvblind (line 122)
[J,P,NUMIT,DAMPAR,READOUT,WEIGHT,sizeI,classI,sizePSF,FunFcn,FunArg] = ...

Error in test2 (line 20)
    [J, P] = deconvblind(Blurred,tmp);

这是重新创建原始 PSF 的好方法吗?

【问题讨论】:

    标签: matlab image-processing fft blur deconvolution


    【解决方案1】:

    我不是这方面的专家,但我玩过一些反卷积,并编写了一个程序来计算给定清晰图像和模糊图像时的点扩散函数。一旦我使用这个程序获得了 psf 函数,我通过使用它对模糊图像进行去卷积验证了它是正确的,并且它工作正常。代码如下。我知道这篇文章已经很老了,但希望它仍然对某人有用。

    import numpy as np
    import matplotlib.pyplot as plt
    import cv2
    
    def deconvolve(normal, blur):
        blur_fft = np.fft.rfft2(blur)
        normal_fft = np.fft.rfft2(normal)
        return np.fft.irfft2(blur_fft/(normal_fft))
    
    img = cv2.imread('Blurred_Image.jpg')
    blur = img[:,:,0]
    img2 = cv2.imread('Original_Image.jpg')
    normal = img2[:,:,0]
    
    psf_real = deconvolve(normal, blur)
    
    
    fig = plt.figure(figsize=(10,4))
    ax1 = plt.subplot(131)
    ax1.imshow(blur)
    ax2 = plt.subplot(132)
    ax2.imshow(normal)
    ax3 = plt.subplot(133)
    ax3.imshow(psf_real)
    plt.gray()
    plt.show() 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-12-20
      • 2011-08-16
      • 2018-02-25
      • 2011-09-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多