Finding a circle in a 2D array

4 visualizaciones (últimos 30 días)
Jack Lavender
Jack Lavender el 16 de En. de 2025
Comentada: Matt J el 27 de En. de 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.

Respuesta aceptada

Matt J
Matt J el 16 de En. de 2025
Editada: Matt J el 16 de En. de 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 comentarios
Jack Lavender
Jack Lavender el 27 de En. de 2025
Movida: Matt J el 27 de En. de 2025
Thanks very much for your answer!
That's great.
Matt J
Matt J el 27 de En. de 2025
You're welcome, but please Accept-click the answer that you decided to use.

Iniciar sesión para comentar.

Más respuestas (1)

Walter Roberson
Walter Roberson el 16 de En. de 2025
Movida: Walter Roberson el 16 de En. de 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 comentario
Jack Lavender
Jack Lavender el 27 de En. de 2025
Thanks very much for your explanation, makes perfect sense.
Cheers!

Iniciar sesión para comentar.

Productos


Versión

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by