Finding a circle in a 2D array

8 visualizzazioni (ultimi 30 giorni)
Jack Lavender
Jack Lavender il 16 Gen 2025
Commentato: Matt J il 27 Gen 2025
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.

Risposta accettata

Matt J
Matt J il 16 Gen 2025
Modificato: Matt J il 16 Gen 2025
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 Commenti
Jack Lavender
Jack Lavender il 27 Gen 2025
Spostato: Matt J il 27 Gen 2025
Thanks very much for your answer!
That's great.
Matt J
Matt J il 27 Gen 2025
You're welcome, but please Accept-click the answer that you decided to use.

Accedi per commentare.

Più risposte (1)

Walter Roberson
Walter Roberson il 16 Gen 2025
Spostato: Walter Roberson il 16 Gen 2025

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 Commento
Jack Lavender
Jack Lavender il 27 Gen 2025
Thanks very much for your explanation, makes perfect sense.
Cheers!

Accedi per commentare.

Prodotti


Release

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by