exponenta event banner

Измерение радиуса рулона ленты

В этом примере показано, как измерить радиус рулона ленты, который частично скрыт устройством выдачи ленты. Использовать 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. The axes 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. The axes contains 5 objects of type line, image, text.

См. также

|

Связанные темы