Main Content

테이프 롤의 반지름 측정

이 예제에서는 테이프 디스펜서에 부분적으로 가려진 테이프 롤의 반지름을 측정하는 방법을 보여줍니다. imfindcircles를 활용하여 이 작업을 수행할 수 있습니다.

1단계: 영상 읽어 들이기

tape.png를 읽어 들입니다.

RGB = imread('tape.png');
imshow(RGB);

hTxt = text(15,15,'Estimate radius of the roll of tape',...
     'FontWeight','bold','Color','y');

Figure contains an axes object. The axes object contains 2 objects of type image, text.

2단계: 원 찾기

imfindcircles 함수를 사용하여 영상에서 원의 중심과 반지름을 찾습니다.

Rmin = 60; 
Rmax = 100;
[center, radius] = imfindcircles(RGB,[Rmin Rmax],'Sensitivity',0.9)
center = 1×2

  236.9291  172.4747

radius = 79.5305

3단계: 원의 윤곽선과 중심을 강조 표시하기

% 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');

Figure contains an axes object. The axes object contains 5 objects of type line, image, text. One or more of the lines displays its values using only markers

참고 항목

|

관련 항목