clock4.m
上传用户:jiaji168
上传日期:2016-05-12
资源大小:816k
文件大小:2k
- clear all;
- I=imread('CLOCK.bmp');
- I=rgb2gray(I);
- %if isa(I,'double')~=1
- %I=double(I);
- %end
- %figure;
- %imshow(I);
- [height width ]=size(I);
- J=zeros(height,width);
- %u=4;
- v=4;
- for u=0:7 %orientations 0-7
-
- sigma = pi/3;%pi*sqrt(2^(-v/2-1));%pi*2;
- sigma_2 = sigma^2;
- kv = pi*2^(-v/2-1);
- phiu = u*pi/8;
- sigma_rule = 3*sigma/kv; %3 sigma rule
- kjx = kv*cos(phiu);
- kjy = kv*sin(phiu);
- for x = -sigma_rule:sigma_rule
- for y = -sigma_rule:sigma_rule
- gaussian_kernal = kv^2/sigma_2*exp(-kv^2*(x^2+y^2)/(2*sigma_2)); %gaussian kernal function
-
- if (abs(x)<=sigma_rule & abs(y)<=sigma_rule)
- gabor_real(x+sigma_rule+1,y+sigma_rule+1) = gaussian_kernal * (cos(kjx*x+kjy*y)-exp(-sigma_2/2));
- gabor_imag(x+sigma_rule+1,y+sigma_rule+1) = gaussian_kernal * sin(kjx*x+kjy*y);
- else
- gabor_real(x+sigma_rule+1,y+sigma_rule+1) = 0;
- gabor_imag(x+sigma_rule+1,y+sigma_rule+1) = 0;
- end
- end
- end
- Imgabout1 = conv2(I,double(gabor_imag),'same');
- Regabout1 = conv2(I,double(gabor_real),'same');
- gabout1 = Regabout1;
- %gabout1 = Imgabout1;
- %for i=2:height-1
- %for j=2:width-1
- %J(i,j)=J(i,j)+gabout1(i,j);
- %end
- %end
- J=J+gabout1;
- end
- %k=255/[max(max(J))-min(min(J))];
- %G=[J-min(min(J))]/k;
- J=J/8;
- for i=1:height
- for j=1:width
- if (J(i,j)<-5)
- J(i,j)=0;
- else J(i,j)=1;
- end
- end
- end
- G=[J-min(min(J))]*255/[max(max(J))-min(min(J))];
- G=uint8(G);
- figure,imshow(G);
- K=imread('pout1.bmp');
- %figure,imshow(K);
- K=double(K);
- K=0.8*K+0.5*J;
- %figure,imshow(K,[]);
-