Can someone break down this code and tell me what it does so I can better understand it?
Mostrar comentarios más antiguos
So far I know the following:
This code first asked the user to choose an image file of choice. The rgb2gray command converts the selected image to grey scale. In the main for loop, the Discrete Fourier Transform of the image is calculated. Once the transform has been done calculating. It is changed to a colormap to reflect the magnitudes of the transform. The absolute value is then plotted on a graph.
Here is the code:
clc;
clear all;
close all;
[filename, pathname, filterindex] = uigetfile( ...
{ '*.jpg','JPEG (*.jpg)'; ...
'*.bmp','Windows Bitmap (*.bmp)'; ...
'*.fig','Figures (*.fig)'; ...
'*.*', 'All Files (*.*)'}, ...
'Choose image(s) to be processed', ...
'MultiSelect', 'off');
if filterindex==0, break;end
filename=cellstr(filename);
im2= imread(horzcat(pathname,char(filename)));
im1=rgb2gray(im2);
im3=im2double(im1);
[n,m]=size(im3);
c1=0;
h = waitbar(0,'Calculating XXX please wait......');
k=1;l=1;
for l=0:1:m-1
for k=0:1:n-1
for x=0:1:n-1
for y=0:1:m-1
a=x+1;b=y+1;
c= im3(a,b) * exp(-1i*2*pi*(k*x/n + l*y/m));
c1=c1+c;
end
end
aa=l+1;bb=k+1;
im(bb,aa)=c1;
c1=0;
end
waitbar(l / m);
end
ims = im*255;
close(h)
imshow(ims);title('XXX plot');
figure
imshow(log(abs(ims)),[-1 5]); colormap(jet); colorbar;title('absolute value of XXX plot');
7 comentarios
Rik
el 2 de Mzo. de 2018
Why did you delete the old question? I'm not going to invest time in writing code for it to be ignored and the question being deleted.
Westin Messer
el 2 de Mzo. de 2018
Stephen23
el 2 de Mzo. de 2018
@Westin Messer: it is often best to keep a discussion in one thread: it makes it easier for everyone to keep track of what information and clarifications have been given.
Westin Messer
el 2 de Mzo. de 2018
Rena Berman
el 2 de Mzo. de 2018
(Answers dev) I undeleted the question.
John BG
el 2 de Mzo. de 2018
good, can we now focus on the question?
Westin Messer
el 2 de Mzo. de 2018
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Image Arithmetic en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

