Detecting circles in videos and measure the diameter

조회 수: 15 (최근 30일)
maroua ghodbene
maroua ghodbene 2020년 10월 15일
답변: Pratheek Punchathody 2020년 10월 21일
How do i detect circular objects in a video or photos ? i have drops in drops and i have to detect both and measure the diameter?

답변 (1개)

Pratheek Punchathody
Pratheek Punchathody 2020년 10월 21일
As per my understanding it is required to detect the circles from the image/video and measure the diameter of the detected circle.
You can use the following code to detect the circle from image attached and calculate the diameter.
%Load the image
a = imread('image.jpeg');
imshow(a);
%Detect the Center and radius
[centers,radii] = imfindcircles(a,[20 25],'ObjectPolarity','dark', 'Sensitivity',0.97);
%Calculate the diameter from radius
diameter = radii*2;
%Visualize circles
viscircles(centers, radii,'Color','r');
In the ”imfindcircles()” and it may also need higher 'Sensitivity' level for better detection of circles. In the current code it is 0.97 which detects all the circles in the image.
The below attached is the image that shows the detected circles from the image:
Refer to the documentation on Detect and Measure Circular Objects in an Image for further details.

카테고리

Help CenterFile Exchange에서 C4ISR에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by