Está en la página 1de 1

%% A) Calculo de histograma % leer imagen, obtener dimensiones, convetir a gray I=imread('C:\Users\CNT01\Desktop\RAMOS\Imagenes\tarea2\lena.

bmp'); [m,n,p]=size(I); gray=rgb2gray(I); %nueva matriz donde se guardara el histograma histgray=zeros(256,1); % calculo histograma gray for k1=1:1:m for k2=1:1:n v=gray(k1,k2)+1; histgray(v,1)=1+histgray(v,1); end end % mostrar histograma calculado figure(1); subplot(1,2,1); plot(histgray); title('Histograma Calculado'); % calcular histograma con imhist de matlab H=imhist(gray); % mostrar hostograma de matlab figure(1); subplot(1,2,2); plot(H); title('Histograma Matlab'); % comprar histogramas a=0; for i=1:1:256 if histgray(i,1)==H(i,1); a=a+1; end end if a==256; disp('Los histogramas son identicos'); else disp('Los histogramas NO son identicos'); end

También podría gustarte