Main Content

Measuring the Radius of a Roll of Tape

This example shows how to measure the radius of a roll of tape, which is partially obscured by the tape dispenser. Utilize imfindcircles to accomplish this task.

Step 1: Read Image

Read in tape.png.

RGB = imread('tape.png');

hTxt = text(15,15,'Estimate radius of the roll of tape',...

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

Step 2: Find the Circle

Find the center and the radius of the circle in the image using imfindcircles.

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

  236.9291  172.4747

radius = 79.5305

Step 3: Highlight the Circle Outline and Center

% Display the circle

% Display the calculated center
hold on;
hold off;

message = sprintf('The estimated radius is %2.1f pixels', radius);

Figure contains an axes. The axes contains 5 objects of type line, image, text.

See Also


Related Topics