Generation of PSF and Applying it to an RGB Image
5 次查看(过去 30 天)
显示 更早的评论
I am trying to generate a PSF from a given data (Phase in radians) and convolve it an RGB image to observe the blurring. But unable to get it right. I would appreciate if I know what would be probably wrong here.
I have provided the code below. It needs to have the attached files while running.
Thanks in advance.
clc;clear;
close all
load Phase.mat
%% Mask
N = size(Phase,1);
x = -N/2:N/2-1;
y = -N/2:N/2-1;
D = 40;
r = length(x);
c = length(y);
Mask = zeros(r,c);
for i=1:r
for j=1:c
if((i-r/2)^2+(j-c/2)^2)^(0.5)<=D
Mask(i,j)=1;
elseif ((i-r/2)^2+(j-c/2)^2)^(0.5)>D
Mask(i,j)=0;
elseif ((i-r/2)^2+(j-c/2)^2)^(0.5)== D
Mask(i,j)=0.5;
end
end
end
%% Point Spread Function
PhaseFT = fftshift(fft2(exp(1i*Phase)));
PSF = abs(PhaseFT.*Mask).^2;
%% Applying PSF to an Image
TestImage = rgb2gray(imread('HST.png'));
Im = conv2(TestImage,PSF,'valid');
figure(1)
imshow(TestImage)
figure(2)
imshow(real(Im))
0 个评论
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!