2

Hi every one >> hope you all are doing fine

I wanted to ask you about calculating the phase values for an image ,, you see I used the Gabor wavlet like so :

k = ( Kmax / ( f ^ v ) ) * exp( 1i * u * pi / 8 );% Wave Vector

kn2 = ( abs( k ) ) ^ 2;

GW = zeros ( R , C );

for m = -R/2 + 1 : R/2

       for n = -C/2 + 1 : C/2 

        GW(m+R/2,n+C/2) = ( kn2 / Delt2 ) * exp( -0.5 * kn2 * ( m ^ 2 + n ^ 2 ) / Delt2) * ( exp( 1i * ( real( k ) * m + imag ( k ) * n ) ) - exp ( -0.5 * Delt2 ) );

    end
end
I=imread('a.pgm');

Myimage=conv2(I,double(GW),'same');

then I called the image and the filter with different orientations and scales and stored the phase in P then I wanted to quantize it with rang 4 i:

close all;
clear all;
clc;

% Parameter Setting

R = 32;
C = 32;
Kmax = pi;
f = sqrt( 2 );
Delt = 2 * pi;
Delt2 = Delt * Delt;

% Show the Gabor Wavelets

for v=1:7 %v = 1 : 7
    for u = 1:5 % u= 1: 5

        [GW,Myimage]= GaborWavelet ( R, C, Kmax, f, u, v, Delt2 ); % Create the Gabor wavelets
       figure;
        subplot( 5, 8, v * 7 + u ),imshow ( real( GW ) ,[]); % Show the real part of Gabor wavelets

    end
   figure ;
    subplot( 1, 5, v + 1 ),imshow ( abs( GW ),[]); % Show the magnitude of Gabor wavelets
end


%clear I;
R=real(GW);

I=imag(GW);

M=abs(Myimage);

P=atan(imag(Myimage)/real(Myimage)); <<<< is this even right ??


%P=atan(I/R);

save P P;

[xx,yy] = size (P);

DATA =zeros(size(P));

for i=1:48
    for j=1:48
        for zz=1:3
           if (360* zz/4) <= abs(P(i,j))&& abs(P(i,j))<(360*(zz+1)/4) 
                 DATA(i,j)=zz ; end;


        end;
    end;
end;
save DATA DATA ;

But the data is so small like : -1.49279186693682 1.50990968797986 -1.39225915272978 0.966151874072431

which leads to quantized value of 0 >> Where did I go wrong

jonsca
  • 10,218
  • 26
  • 54
  • 62
Rand
  • 21
  • 2
  • I think you will need to add some more explanation before the regular matlab users can help you with this. For example: Untill what point does the program do what you expect? And when it does not behave as expected, what does it do and what did you expect exactly? – Dennis Jaheruddin Sep 17 '12 at 10:26

1 Answers1

0

I think values seem small because they are given in radians and you expect them in degrees. As for getting the magnitude and angle of a complex number, take a look at http://www.mathworks.fr/fr/help/matlab/ref/angle.html.

I quote:

"For complex Z, the magnitude R and phase angle theta are given by

R = abs(Z)

theta = angle(Z)"

Z would be your GW.

Hope this helps!

Milo
  • 2,062
  • 16
  • 38