Error while differentiating the image

조회 수: 2 (최근 30일)
Minseo Jeong
Minseo Jeong 2022년 2월 24일
편집: Minseo Jeong 2022년 2월 25일
I want to reconstruct the first image using radial profile. However, an error happened during the reconstruction process. The result of code is supposed to be in shape of second picture, but its result has a shape of fourth picture. The third picture is the shape of variable abs(display_profile). Does somebody know why this error is happening?
theta = 0:359; % [Degree]
theta_rad = theta*pi/180; % [Radian]
x = -600:600; % [um] 1 px = 1 um
y = -600:600; % [um] 1 px = 1 um
sw = 100; % FWHM of source size : 100 um
% Making source image on the source plane
s = zeros([1201,1201]);
for n = 1:1201 % Index for x coordinate
for k = 1:1201 % Index for y coordinate
s(k,n) = exp(-4*log(2)*(x(n)^2/sw^2 + y(k)^2/sw^2)/2);
end
end
figure(1)
imagesc(s)
title('Source image'); colorbar()
% Maing aperture with size of 500 um
aper = zeros([1201,1201]);
for n = 1:1201 % Index for x coordinate
for k = 1:1201 % Index for y coordinate
if x(n)^2 + y(k)^2 <= 250^2
aper(k,n) = 1;
end
end
end
figure(2)
imagesc(aper)
title('Aperture'); colorbar()
%% 2D FFT
S = fftshift(fft2(s)); % Source in spatial frequncy domain
AP = fftshift(fft2(aper)); % Aperture in spatial frequency domain
% H1 and H2 should be replaced with proper function
H1 = 1; % Free space propagation transfer function from source to aperture
H2 = 1; % Free space propagation transfer function from aperture to detector
OBJ = H2.*AP.*H1.*S; % Penumbra image on detector plane in spatial frequency domain
obj = ifftshift(ifft2(OBJ)); % Penumbra image on detector plane in real space domain
figure(10)
imagesc(abs(obj))
Nprofile=length(theta_rad);
rho_start=0;
rho_end=600;
[x_start, y_start]=pol2cart(theta_rad,repelem(rho_start,1,Nprofile));
xs=x_start+600;
ys=y_start+600;
[x_end, y_end]=pol2cart(theta_rad, repelem(rho_end,1,Nprofile));
xe=x_end+600;
ye=y_end+600;
Npoint=600;
[Nu,Nx,Nc]=size(obj);
profile=zeros(Npoint,Nc,Nprofile);
for k=1:Nprofile
profile(:,:,k)=improfile(obj,[xs(k) xe(k)],[ys(k) ye(k)],Npoint);
end
display_profile=permute(flipud(profile), [1 3 2]);
figure
imagesc(abs(display_profile));
figure
Y=diff(display_profile,1,1);
imagesc(abs(Y));

답변 (0개)

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by