Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- % --------------------------------------------------------------------
- function erosion_Callback(hObject, eventdata, handles)
- % hObject handle to erosion (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- image=handles.courant_data;
- se = strel('disk',8);
- b = imerode(image,se);
- handles.ima_traite = b;
- axes(handles.imgT);
- subimage(b);
- handles.output = hObject;
- guidata(hObject, handles);
- % --------------------------------------------------------------------
- function dilatation_Callback(hObject, eventdata, handles)
- % hObject handle to dilatation (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- image=handles.courant_data;
- se = strel('disk',8);
- b = imdilate(image,se);
- handles.ima_traite = b;
- axes(handles.imgT);
- subimage(b);
- handles.output = hObject;
- guidata(hObject, handles);
- % --------------------------------------------------------------------
- function ouverture_Callback(hObject, eventdata, handles)
- % hObject handle to ouverture (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- image=handles.courant_data;
- se = strel('disk',3);
- b = imopen(image,se);
- handles.ima_traite = b;
- axes(handles.imgT);
- subimage(b);
- handles.output = hObject;
- guidata(hObject, handles);
- % --------------------------------------------------------------------
- function fermeture_Callback(hObject, eventdata, handles)
- % hObject handle to fermeture (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- image=handles.courant_data;
- se = strel('line',11,90);
- b = imclose(image,se);
- %imshow(b);
- handles.ima_traite = b;
- axes(handles.imgT);
- subimage(b);
- handles.output = hObject;
- guidata(hObject, handles);
- % --------------------------------------------------------------------
- function tophat_Callback(hObject, eventdata, handles)
- % hObject handle to tophat (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- image=handles.courant_data;
- se = strel('disk',30);
- b = imtophat(image,se);
- handles.ima_traite = b;
- axes(handles.imgT);
- subimage(b);
- handles.output = hObject;
- guidata(hObject, handles);
- % --------------------------------------------------------------------
- function bottom_hat_Callback(hObject, eventdata, handles)
- % hObject handle to bottom_hat (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- image=handles.courant_data;
- se = strel('disk',30);
- b = imbothat(image,se);
- handles.ima_traite = b;
- axes(handles.imgT);
- subimage(b);
- handles.output = hObject;
- guidata(hObject, handles);
- % --------------------------------------------------------------------
- function gradient_interne_Callback(hObject, eventdata, handles)
- % hObject handle to gradient_interne (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- image=handles.courant_data;
- se = strel('disk',3);
- b = imerode(image,se);
- img = image - b;
- handles.ima_traite = img;
- axes(handles.imgT);
- subimage(img);
- handles.output = hObject;
- guidata(hObject, handles);
- % --------------------------------------------------------------------
- function gradient_externe_Callback(hObject, eventdata, handles)
- % hObject handle to gradient_externe (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- image=handles.courant_data;
- se = strel('disk',3);
- b = imdilate(image,se);
- img = b - image ;
- handles.ima_traite = img;
- axes(handles.imgT);
- subimage(img);
- handles.output = hObject;
- guidata(hObject, handles);
- % --------------------------------------------------------------------
- function gradient_morphologique_Callback(hObject, eventdata, handles)
- % hObject handle to gradient_morphologique (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- image=handles.courant_data;
- se = strel('disk',3);
- a= imerode(image,se);
- b = imdilate(image,se);
- img = b - a ;
- handles.ima_traite = img;
- axes(handles.imgT);
- subimage(img);
- handles.output = hObject;
- guidata(hObject, handles);
- % --------------------------------------------------------------------
- function harris_Callback(hObject, eventdata, handles)
- % hObject handle to harris (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- img = handles.courant_data;
- %==========================================================================
- if(size(img,3)==3)
- display('l''image est en couleur')
- img=rgb2gray(img);
- end
- %==========================================================================
- lambda=0.04;
- sigma=1; seuil=200; r=6; w=5*sigma;
- [m,n]=size(img)
- imd=double(img);
- dx=[-1 0 1
- -2 0 2
- -1 0 1]; % derivée horizontale : filtre de Sobel
- dy=dx'; % derivée verticale : filtre de Sobel
- % dx=[-1 1];
- % dy=dx';
- g = fspecial('gaussian',max(1,fix(w)), sigma);
- Ix=conv2(imd,dx,'same');
- Iy=conv2(imd,dy,'same');
- Ix2=conv2(Ix.^2, g, 'same');
- Iy2=conv2(Iy.^2, g, 'same');
- Ixy=conv2(Ix.*Iy, g,'same');
- % M=[Ix2 Ixy
- % Ixy Iy2];
- detM=Ix2.*Iy2-Ixy.^2;
- trM=Ix2+Iy2;
- R=detM-lambda*trM.^2;
- %==========================================================================
- R1=(1000/(1+max(max(R))))*R;
- %==========================================================================
- [u,v]=find(R1<=seuil);
- nb=length(u);
- for k=1:nb
- R1(u(k),v(k))=0;
- end
- R11=zeros(m+2*r,n+2*r);
- R11(r+1:m+r,r+1:n+r)=R1;
- [m1,n1]=size(R11);
- for i=r+1:m1-r
- for j=r+1:n1-r
- fenetre=R11(i-r:i+r,j-r:j+r);
- ma=max(max(fenetre));
- if fenetre(r+1,r+1)<ma
- R11(i,j)=0;
- end
- end
- end
- subplot(1,2,2); imshow(img)
- hold on
- R11=R11(r+1:m+r,r+1:n+r);
- [x,y]=find(R11);
- nb=length(x)
- plot(y,x,'.r')
- hold off
- % --------------------------------------------------------------------
- function susan_Callback(hObject, eventdata, handles)
- % hObject handle to susan (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- % =====================chargement et conversion de limage==================
- im = handles.courant_data;
- % =======================conversion de l'image=============================
- d = length(size(im));
- % im = imnoise(im,'speckle',0.02);
- if d==3
- image=double(rgb2gray(im));
- elseif d==2
- image=double(im);
- end
- %subplot(1,2,1)
- %imshow(im)
- [n,m]=size(image);
- % =============================données=====================================
- rayon=2;
- alpha=50;
- r=2;
- alpha=alpha/100;
- % ========================génerateur de mask===============================
- mask=zeros(2*rayon+1);
- b=ones(rayon+1);
- for i=1:rayon+1
- for j=1:rayon+1
- if (rayon==1)
- if(j>i)
- b(i,j)=0;
- end
- else
- if(j>i+1)
- b(i,j)=0;
- end
- end
- end
- end
- mask(1:rayon+1,rayon+1:2*rayon+1)=b;
- mask(1:rayon+1,1:rayon+1)=rot90(b);
- mask0=mask;
- mask0=flipdim(mask0,1);
- mask=mask0+mask;
- mask(rayon+1,:)=mask(rayon+1,:)-1;
- % ==========================réponse maximale===============================
- max_reponse=sum(sum(mask));
- % =====================balayage de toute l'image===========================
- f=zeros(n,m);
- for i=(rayon+1):n-rayon
- for j=(rayon+1):m-rayon
- image_courant=image(i-rayon:i+rayon,j-rayon:j+rayon);
- image_courant_mask=image_courant.*mask;
- inteniste_cental= image_courant_mask(rayon+1,rayon+1);
- s=exp(-1*(((image_courant_mask-inteniste_cental)/max_reponse).^6));
- somme=sum(sum(s));
- % si le centre du mask est un 0 il faut soustraire les zeros des filtres
- if (inteniste_cental==0)
- somme=somme-length((find(mask==0)));
- end
- f(i,j)=somme;
- end
- end
- % =============selection et seuillage des points d'interét=================
- ff=f(rayon+1:n-(rayon+1),rayon+1:m-(rayon+1));
- minf=min(min(ff));
- maxf=max(max(f));
- fff=f;
- d=2*r+1;
- temp1=round(n/d);
- if (temp1-n/d)<0.5 &(temp1-n/d)>0
- temp1=temp1-1;
- end
- temp2=round(m/d);
- if (temp2-m/d)<0.5 &(temp2-m/d)>0
- temp2=temp2-1;
- end
- fff(n:temp1*d+d,m:temp2*d+d)=0;
- temp1
- temp2
- fff;
- sizefff=size(fff)
- for i=(r+1):d:temp1*d+d
- for j=(r+1):d:temp2*d+d
- window=fff(i-r:i+r,j-r:j+r);
- window0=window;
- [xx,yy]=find(window0==0);
- for k=1:length(xx)
- window0(xx(k),yy(k))=max(max(window0));
- end
- minwindow=min(min(window0));
- [y,x]=find(minwindow~=window & window<=minf+alpha*(maxf-minf) & window>0);
- [u,v]=find(minwindow==window);
- if length(u)>1
- for l=2:length(u)
- fff(i-r-1+u(l),j-r-1+v(l))=0 ;
- end
- end
- if length(x)~=0
- for l=1:length(y)
- fff(i-r-1+y(l),j-r-1+x(l))=0 ;
- end
- end
- fff;
- end
- end
- seuil=minf+alpha*(maxf-minf);
- [u,v]=find(minf<=fff & fff<=seuil );
- % ==============affichage des resultats====================================
- subplot(1,2,2);
- imshow(im)
- hold on
- %axes(handles.imgT);
- plot(v,u,'.r','MarkerSize',10)
- %nombre_de_point_dinteret=length(v)
- hold off
- %handles.ima_traite = im;
- %subimage(im);
- %handles.output = hObject;
- %guidata(hObject, handles);
- % --------------------------------------------------------------------
- function electrostatique_Callback(hObject, eventdata, handles)
- % hObject handle to electrostatique (see GCBO)
- % eventdata reserved - to be defined in a future version of MATLAB
- % handles structure with handles and user data (see GUIDATA)
- img = handles.courant_data;
- k=0.04; sigma=1; seuil=100; r=6; w=5*sigma;
- [m,n]=size(img); imd=double(img);
- dxa=[-sqrt(2)/4 0 sqrt(2)/4 ; -1 0 1 ; -sqrt(2)/4 0 sqrt(2)/4];
- % dxa=[sqrt(2)/4 0 -sqrt(2)/4; 1 0 -1; sqrt(2)/4 0 -sqrt(2)/4];
- dya=dxa'; % derivée verticale
- g=fspecial('gaussian',max(1,fix(5*sigma)),sigma); % gaussien
- Ixa=conv2(imd,dxa,'same');
- Iya=conv2(imd,dya,'same');
- Ixa2 = conv2(Ixa.^2, g, 'same');
- Iya2 = conv2(Iya.^2, g, 'same');
- Ixya = conv2(Ixa.*Iya, g,'same');
- R=Ixa2.*Iya2-Ixya.^2-k*(Ixa2+Iya2).^2;
- R1=(1000/(max(max(R))))*R; %normalisation
- [u,v]=find(R1<=seuil);
- nb=length(u);
- for k=1:nb
- R1(u(k),v(k))=0;
- end
- R11=zeros(m+2*r,n+2*r);
- R11(r+1:m+r,r+1:n+r)=R1;
- [m1,n1]=size(R11);
- for i=r+1:m1-r
- for j=r+1:n1-r
- fenetre=R11(i-r:i+r,j-r:j+r);
- ma=max(max(fenetre));
- if fenetre(r+1,r+1)<ma
- R11(i,j)=0;
- end
- end
- end
- subplot(1,2,2); imshow(img)
- hold on
- R11=R11(r+1:m+r,r+1:n+r);
- [x,y]=find(R11);
- nb=length(x)
- plot(y,x,'.r')
- %title('detection des points d''interet')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement