Filter löschen
Filter löschen

what the right function ?

2 Ansichten (letzte 30 Tage)
deniel munthe
deniel munthe am 29 Apr. 2012
any body can help me?
i'm a newbie with matlab.
why this function error. "function I= checkered(N,s)"
% Prepare image
f = zeros(30,30);
f(5:24,13:17) = 1;
imshow(f,'notruesize')
% Compute Fourier Transform
F = fft2(f,256,256);
F = fftshift(F); % Center FFT
% Measure the minimum and maximum value of the transform amplitude
min(min(abs(F))) % 0
max(max(abs(F))) % 100
imshow(abs(F),[0,100]); colormap(jet); colorbar
imshow(log(1+abs(F)),[0,3]); colormap(jet); colorbar
% * What is the main difference between representing the amplitude and its logarithm?
% Look at the phases
imshow(angle(F),[-pi,pi]); colormap(jet); colorbar
% * Try with other images
f = imread('fotokanker1.jpg');
f = ind2gray(f,gray(256));
% * Or more patterned from Yamitani (at Caltech Univ.) homepage.
% * Checkered images
function I= checkered(N,s)
% This function returns a checkered image of size N
% and with a check size of s
I=zeros(N,N);
for i=1:N,
for j=1:N,
if (mod(floor(i/s)+floor(j/s),2)==0) I(i,j)=1; end;
end;
end;
f=checkered(256,32); imshow(f);
  1 Kommentar
Image Analyst
Image Analyst am 29 Apr. 2012
In the Image Processing Toolbox, there is a checkerboard() function.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

per isakson
per isakson am 29 Apr. 2012
If checkered is supposed to be a nested function if must be closed with the keyword end.
  1 Kommentar
deniel munthe
deniel munthe am 29 Apr. 2012
owh, ok .
thanks a lot of.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Wayne King
Wayne King am 29 Apr. 2012
It looks to me like this function is ok. I mean you don't need the semicolons after the ends, but ok fine.
Did you save this checkered.m file somewhere on your path? Then you can call it with:
f=checkered(256,32); imshow(f);
Don't try to execute this whole thing as a script, maybe that is what you are doing wrong. Pull out the function and save that in a separate checkered.m file.
  1 Kommentar
deniel munthe
deniel munthe am 29 Apr. 2012
yes I save it with the name checkered.m
so I should not combine the functions of these at once.
Thank you very much

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Colormaps finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by