Skip to content

Instantly share code, notes, and snippets.

@nelsondspy
Created April 14, 2015 00:30
Show Gist options
  • Save nelsondspy/a3630925e7d1d772540c to your computer and use it in GitHub Desktop.
Save nelsondspy/a3630925e7d1d772540c to your computer and use it in GitHub Desktop.
morfología de imágenes binarias tema 1
function tema1()
SOL1();
end
function SOL1()
I = im2bw( imread('binbolin.bmp') );
%para que los elementos de interes tengan valor 1 y resto 0
Ic = ~I;
%elemento estructurante con forma de disco de radio 2
ES1 = strel('disk', 2);
%la erosion deja solo los circulos
R1= nimerosion(Ic, ES1, 1);
imshow(R1);
%se eliminan los circulos restandolos de la imagen principal, se dilata R1
%para compensar la erosion aplicada anteriormente
R2 = Ic - nimdilatacion(R1,ES1,1 );
%se vuelve a complementar para obtener el color original
R2 = ~R2;
%imagenes
figure;
imshow(R2);
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment