Receiving NaN when using iradon function
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I'm tring the inverse radon transform of image, but I receive NaN error when I use iradon function.
Doen anyone know why is this happening and how to solve the problem?
Here is the code used to make the image.
theta = 0:1: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 l = 1:1201 % Index for y coordinate
s(l,n) = exp(-4*log(2)*(x(n)^2/sw^2 + y(l)^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(3)
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;
profile=zeros(Npoint,1,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));
abdis=abs(display_profile);
%differentiation of radial profile image
figure
Y=diff(abdis,1,1);
imagesc(imfilter(abs(Y),ones(35)/35,'replicate'))
YY=imfilter(abs(Y),ones(35),'replicate');
A=iradon(YY,theta);
figure
imagesc(A)
0 comentarios
Respuestas (1)
Benjamin Thompson
el 2 de Mzo. de 2022
Editada: Benjamin Thompson
el 2 de Mzo. de 2022
You can use max(max(isnan(xe))) to check if any variables created while running your code have a NaN. Looking through them after running your code, improfile is getting complex-valued image input and per its documentation it does not support that data type. That would be my guess why NaNs start to appear in the output of the code at that point.
2 comentarios
Benjamin Thompson
el 3 de Mzo. de 2022
If you type the command "doc improfile" in MATLAB, or go to the documentation of the function online at https://www.mathworks.com/help/images/ref/improfile.html?s_tid=srchtitle_improfile_1, you will see that the datatypes allowable for the input image argument do not include complex arrays.
I — Input image
RGB image | grayscale image | binary image
Input image, specified as an RGB image, grayscale image, or binary image.
Data Types: single | double | int16 | uint8 | uint16 | logical
Ver también
Categorías
Más información sobre Detection en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!