You are on page 1of 2

Alumno:

López Peña, José Rodolfo 1212514

Pregunta N°1
%Conversión de COLOR a GRIS
M4 = imread('Lago.jpg');
R = M4( : , : , 1 );
G = M4( : , : , 2 );
B = M4( : , : , 3 );
M7 = round( (R + G + B ) / 3 );
colormap( gray( 256 ) )
subplot(121), image( M7 )
M8 = round( 0.299*R + 0.587*G + 0.114*B );
colormap( gray( 256 ) )
subplot(122), image( M8 )
subplot(121), image( M4 )

% Mejora del Contraste


m = min(min ( M8) );
M = max(max ( M8 ) )
M8 = double( M8 );
m = double(m); M = double(M );
B = round( ( ( M8 - m ) / ( M - m ) ) * 255 );
B = uint8 ( B );
subplot(221), image( M8 )
subplot(222), imhist( uint8( M8 ) )
subplot(223), image( B )
subplot(224), imhist( B )

%Transformando GRIS a B/N


subplot(121), image( B )
umbral = 100;
M9 = im2bw( B, umbral / 255 );
subplot(122), image( M9 * 255 )

%Para convertir imagen binaria a un color específico


colormap(gray(256))
subplot(121), image( M9*255 )
[ f , c ] = size(M9);
M = zeros( f , c , 3 );
for i=1:f
for j=1:c
if M9(i,j) == 1
M(i,j,1) = 0; M(i,j,2) = 255; M(i,j,3) = 40;
else
M(i,j,1) = 0; M(i,j,2) = 0; M(i,j,3) = 255;
end
end
end
subplot(122), image( uint8( M) )

% Comparando las imágenes


subplot(121), image( M4 )
subplot(122), image( uint8( M) )

Diagrama de bloques

You might also like