pcolor with complex data

my all code is this:
a=imread('plus_white.gif');
[m n]=size(a);
lambda=600e-9;
f=16.5e-9;
w=4e-3;
k = (fftshift(fft2(a))).^2;
x = linspace(-lambda*f*n/(2*w), lambda*f*n/(2*w), n);
y = linspace(-lambda*f*m/(2*w), lambda*f*m/(2*w), m);
pcolor(x,y,k);
the code is taken from Stephen Schultzs' Using MATLAB to compute diffraction patterns of complex apertures.
??? Error using ==> pcolor at 62 Data inputs must be real.
k is like that 2.645177387196637e+02 + 2.156307053870210e+02i I don't want to loose my data by changing it int type what i can do for it?

 채택된 답변

Image Analyst
Image Analyst 2013년 1월 1일

0 개 추천

First of all, you should change the name of the badly-named I to something else. It looks too much like a 1 or an l. Call it something descriptive, like theSpectrum. Then you should use image() or imshow() instead because pcolor does not display the last column or row of your matrix (proof: pcolor(rand(4))).
imshow(log(real(theSpectrum)));
or you can use imag() or norm() or whatever. Taking the log will compress the display so you can actually see it, since usually the DC spike is so huge that it makes all the higher frequencies hard to see. Or impossible, if they are less than 1/255 the height of the DC spike.
After that, you can apply a colormap if you want:
colormap(jet(256));
colorbar;

댓글 수: 1

geem
geem 2013년 1월 1일
Thank you for reply i'll try all of them.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Images에 대해 자세히 알아보기

질문:

2013년 1월 1일

Community Treasure Hunt

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

Start Hunting!

Translated by