我正在尝试对下面图片的模糊部分进行模糊处理。

原始的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的好方法吗?
发布于 2018-12-12 22:31:50
我不是这个领域的专家,但我玩过一点反卷积,并写了一个程序来计算点扩散函数,当给定一个清晰的图像和一个模糊的图像时。一旦我使用这个程序得到了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() https://stackoverflow.com/questions/30564417
复制相似问题