Finding a circle in a 2D array

4 ビュー (過去 30 日間)
Jack Lavender
Jack Lavender 2025 年 1 月 16 日
コメント済み: Matt J 2025 年 1 月 27 日
This is not circle finding in an image, which has been well covered, but in an array.
I have an array P with several approximately-circular areas of a low value. I would like to find the centres of those areas to calibrate my device. Here is a contour 2D plot of P. The contour plot looks a bit odd because I only obtained a patch of data around each circle (the box) and it is doing a linear interpolation between those.
This is a one-time calibration so I'm happy to do some manual setting up work.
Thanks in advance!
Jack
This is how I display the contour:
figure(1)
pcolor(X,Y,P);
shading interp
hold on
colorbar
hold off
PS this is my first question so do say if there is anything I can improve for next time.

採用された回答

Matt J
Matt J 2025 年 1 月 16 日
編集済み: Matt J 2025 年 1 月 16 日
load P
BW=median(P(:))-P>50;
BW=bwpropfilt(bwareaopen(BW,100),'Eccentricity',6,'small');
c=vertcat(regionprops(BW,'Centroid').Centroid);
imagesc(BW);colormap(gray); axis off; hold on
plot(c(:,1),c(:,2),'r.','MarkerSize',12); hold off
  2 件のコメント
Jack Lavender
Jack Lavender 2025 年 1 月 27 日
移動済み: Matt J 2025 年 1 月 27 日
Thanks very much for your answer!
That's great.
Matt J
Matt J 2025 年 1 月 27 日
You're welcome, but please Accept-click the answer that you decided to use.

サインインしてコメントする。

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2025 年 1 月 16 日
移動済み: Walter Roberson 2025 年 1 月 16 日

There are no functions to find circles in "images" : there are only functions to find circles in arrays. When it is necessary to find circles in "images", the program must first read the image file into an array, and then find circles in the array that was read in.

There is no difference in circle finding routines between the case where the array was read from an image file, compared to the case where the array was computed.

  1 件のコメント
Jack Lavender
Jack Lavender 2025 年 1 月 27 日
Thanks very much for your explanation, makes perfect sense.
Cheers!

サインインしてコメントする。

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by