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

参考

|

関連するトピック