Medir el radio de un rollo de cinta
Este ejemplo muestra cómo medir el radio de un rollo de cinta que está parcialmente oculto por el portarrollos. Utilice imfindcircles
para realizar esta tarea.
Paso 1: Leer la imagen
Lea tape.png
.
RGB = imread('tape.png'); imshow(RGB); hTxt = text(15,15,'Estimate radius of the roll of tape',... 'FontWeight','bold','Color','y');
Paso 2: Encontrar el círculo
Encuentre el centro y el radio del círculo de la imagen utilizando imfindcircles
.
Rmin = 60;
Rmax = 100;
[center, radius] = imfindcircles(RGB,[Rmin Rmax],'Sensitivity',0.9)
center = 1×2
236.9291 172.4747
radius = 79.5305
Paso 3: Destacar el contorno y el centro del círculo
% Display the circle viscircles(center,radius); % Display the calculated center hold on; plot(center(:,1),center(:,2),'yx','LineWidth',2); hold off; delete(hTxt); message = sprintf('The estimated radius is %2.1f pixels', radius); text(15,15,message,'Color','y','FontWeight','bold');