Professional Documents
Culture Documents
Stphane BAZEILLE
Le 13 mars 2006
Introduction Matlab
1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.1 2.2 2.3 2.4 2.5 2.6 2.7
Q'est-ce que MATLAB . . Les variables . . . . . . . Les oprations matricielle Les variables prdnies . Les fonctions . . . . . . . Conditions et boucles . . . Les entres sorties . . . . Structure des programmes Les toolboxes . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
2 2 3 3 3 4 4 4 4 5 5 5 6 6 6 6
Image Processing Toolbox . . . . . . . . . . . Codage d'une image, reprsentation spatiale . Lecture, criture et achage d'une image . . Histogramme d'une image . . . . . . . . . . . Filtrage linaire et convolution . . . . . . . . Transformation et rprsentation frquentielle Dtection de contours . . . . . . . . . . . . .
Chapitre 1
Introduction Matlab
inv(A) inverse d'une matrice det(A) dterminant d'une matrice rank(A) rang d'une matrice.
Chapitre 2
Traitement d'image sous MATLAB
Ecriture d'une image : fonction imwrite Achage d'une image : fonction imshow, imagesc
Chapitre 3
Un peu de code. . .
clear;close all; %Matrice a=[1 -1;0 1] b=[1 2;-3 1] c=[4 -3;1 1] ((a*b)'*1/c)*a %Matrice inverse d=[1 3;3 -1]; comd=[-1 -3;-3 1]; comd'*1/det(d) inv(d) %Rsolution de systeme a=[3 2 -1 -1;2 -1 -1 1;1 2 -2 1;-1 -1 -3 2]; b=[0;1;3;-4]; a\b inv(a)*b %Polynome %p=x^4-12*x^3+25*x+116 p=[1 -12 0 25 116] r=roots(p) sum(r)
%Calcul x=linspace(-15,15,100); f=x.^5-3*x.^4-11*x.^3+27*x.^2+10*x-24; df=diff(f)./diff(x); dx= x(2:length(x)); figure;plot(x,f,dx,df); %Plot 3D [x,y] = meshgrid(-3:0.1:3); z = (x+y).*exp(-(x.^2 + y.^2)); figure;mesh(z); %Premiere image b=zeros(100,100); b(35:65,35:65)=255; figure;imshow(b); %Convolution Laplacien im=imread('cameraman.tif'); im=double(im)/255; im=imnoise(im,'gaussian',0,0.1); l=[-1 -1 -1;-1 8 -1;-1 -1 -1]; figure;imshow(im); imf=conv2(im,l); figure;imshow(imf); g=ones(5,5)/25; %g=[1 1 1;1 1 1;1 1 1]/9; %g=[1 2 1;2 4 2;1 2 1]/16; im=conv2(im,g); figure;imshow(im); %imf=conv2(im,l); %figure;imshow(imf); sx=[-1 -2 -1;0 0 0;1 2 1]; sy=[-1 0 1;-2 0 2;-1 0 1]; ga=conv2(im,sx); gb=conv2(im,sy); figure;imshow(ga); figure;imshow(gb); figure;imshow(ga+gb); norme=sqrt(ga.^2+gb.^2);
coutour=zeros(258,258); m=mean(mean(norme)); for ii=1:258 for jj=1:258 if(norme(ii,jj)>m)contour(ii,jj)=1;end end end figure;imshow(contour);