MATLAB: The effect of PSF in x-ray image

digital image processingimage processingImage Processing Toolbox

hi am trying to find the effect of the PSF on x-ray image , i generate the psf using a for loop then use convolution with the image , after that taking fft for both PSF and image seeing the spectrum … but after conv function and ifft it give black image why?
clc
clear all
close all
im=imread('xray2.jpg');
[m,n]=size(im);
PSF=zeros(n,m);
Y=size(PSF,1);
X=size(PSF,2);
s_x=1;
s_y=5;
for x=1:X
for y=1:Y
PSF(y,x) = exp(-((x-X).^2/(2*s_x^2) + (y-Y).^2)/(2*s_y^2));
end
end
%Display PSF
figure(1)
imshow(PSF)
title('PSF')
colormap gray
figure(2)
imshow(im)
colormap cool
title('x-ray image for hand') %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
im_conv=convn(im,PSF,'full');
figure(3)
imshow(im_conv)
title('x-ray image convolved with PSF') %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
psf_fft=fftshift(fft2(PSF));
im3=fft2(PSF);
fft_res=psf_fft.*im3;
figure(4)
imshow(fft_res)
title('the ruselt of FFT ') %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
im4=ifft(fft_res);
figure(5)
imshow(im4)
title('IFFT')

Best Answer

im needs to be cast to double, and you need to use [] in imshow(fft_res, []). And you can also use conv2() instead of convn().