Filter löschen
Filter löschen

NaN value.....​..........​......

7 Ansichten (letzte 30 Tage)
x
x am 20 Sep. 2011
I=imread('cameraman.tif'); I=imresize(I,[32,32]); imshow(I); I=double(I); [M N]=size(I); imSize=M*N;
%Normalizatk1on maximum=max(max(I)); NI=I/maximum;
%EXTENDED ANALYTIC SIGNAL OUTPUT
%Hilbert Transform for k1=1:M for k2=1:N H(k1,k2)=(1/pi)*I(k1,k2); %k11(k1,k2)=k1*hk1lbert((k1(k1,k2))); end end
for k1=1:M for k2=1:N Icap(k1,k2)=I(k1,k2)+k1*H(k1,k2); end end %STEERABLE PYRAMID nlevels=input('Enter the number of levels to be decomposed:'); nbands=input('Enter the number of orientation Bands:'); [pyr,pind] = buildSFpyr(abs(Icap),nlevels,nbands); showSpyr(pyr,pind); [m n]=size(pind);
% level=nlevels; % band=nbands; % res = spyrBand(pyr,pind,level,band); res = reconSFpyr(pyr,pind); imStats(abs(Icap),res); figure, showIm(res); % nbands=spyrNumBands(pind);
for k=1:m %PROCESSED BAND band=input('Enter the band to be selected:'); res = pyrBand(pyr, pind, band); figure,imagesc(res);colormap('gray'); [p q]=size(res); %Instantaneous Amplitude and Phase Component for k1=1:M for k2=1:N amp(k1,k2)=sqrt((real(res(k1,k2)))^2+(imag(res(k1,k2)))^2); %amp(k1,k2)=sqrt((res(k1,k2)))^2; amp(k1,k2)=abs(amp(k1,k2)); if p<M for i=p+1:M for j=q+1:N res(i,j)=0; end end end Ibar(k1,k2)=res(k1,k2)/amp(k1,k2); % phi(k1,k2)=atan(imag(res(k1,k2))/real(res(k1,k2)));
end
end
Ibar = padarray(Ibar, [1 1]); [phi1,phi2,phi3,phi4]=phase(Ibar,M,N); % for k1=2:M % for k2=2:N % N(k1,k2)=Ibar(k1+1,k2)-Ibar(k1-1,k2); % D(k1,k2)=2*i*Ibar(k1,k2); % C1(k1,k2)=sign(real(N(k1,k2)/D(k1,k2))); % for n1=1 % G(k1,k2)=(Ibar(k1+1,k2)+Ibar(k1-1,k2))/(2*i*Ibar(k1,k2)); % phi1(k1,k2)=acos(G(k1,k2))/n1;phi1(k1,k2)=abs(phi1(k1,k2)); % end % for n1=2 % G(k1,k2)=(Ibar(k1+1,k2)+Ibar(k1-1,k2))/(2*i*Ibar(k1,k2)); % phi2(k1,k2)=acos(G(k1,k2))/n1;phi2(k1,k2)=abs(phi2(k1,k2)); % end % for n1=3 % G(k1,k2)=(Ibar(k1+1,k2)+Ibar(k1-1,k2))/(2*i*Ibar(k1,k2)); % phi3(k1,k2)=acos(G(k1,k2))/n1;phi3(k1,k2)=abs(phi3(k1,k2)); % end % for n1=4 % G(k1,k2)=(Ibar(k1+1,k2)+Ibar(k1-1,k2))/(2*i*Ibar(k1,k2)); % phi4(k1,k2)=acos(G(k1,k2))/n1;phi4(k1,k2)=abs(phi4(k1,k2)); % end % end % end end
Phi values returning from the pgm are NaN values...............How to debug?
  2 Kommentare
Jan
Jan am 20 Sep. 2011
Please format your code, see e.g. http://www.mathworks.com/matlabcentral/answers/13205-tutorial-how-to-format-your-question-with-markup or follow the "Markup help" link on this page.
Walter Roberson
Walter Roberson am 8 Okt. 2011
It needs more work than that -- the code is badly formatted in the editor :(

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Jan
Jan am 20 Sep. 2011
NaN value are replied for divisions by zero. Therefore it might help to enable the corresponding warning:
warning on MATLAB:divideByZero
Otherwise you create a breakpoint in the code to stop Matlab in each iteration and observe if the NaNs appeared already.
Finally you can include a section of code, to do this for you:
...
if any(isnan(Phi(:)))
disp('NaN!');
end
and set a breakpoint to the "disp..:" line. To learn more about breakpoints, search for "debugger" or "breakpoint" in the documentation.
  2 Kommentare
x
x am 8 Okt. 2011
i am using normalized values in my code..in that some patches i am setting my ans as 0/0=NAN form what to do for that sir
Jan
Jan am 8 Okt. 2011
Most of all: please format your code to make it readable. As long as you do not care about the readers, they will not care much about your question.

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by