Calculate radius from scatter plot

Hi,
I need to calculate the radius of a circle, ignoring all surrounding particles (image attached). The circle itself consists of many particles (over 100,000). Note that the center of the circle is not at the origin.
Thanks.
EDIT: here is how I solved it:
posn=normal(poscm); %poscm is the coordinates matrix
[k,edges]=histcounts(posn,1e5);
[~,imaxk]=max(k);
R=edges(imaxk+find(k(imaxk:end)==0,1)); %find the first zero value after the maximum

5 commentaires

Adam Danz
Adam Danz le 22 Juin 2020
I assume you're computing the radius based on a set of coordinates, or are you computing it based on the image?
yonatan s
yonatan s le 22 Juin 2020
based on a set of coordinates
Adam Danz
Adam Danz le 22 Juin 2020
Modifié(e) : Adam Danz le 22 Juin 2020
Some ideas off the top of my head.....
There are several things you could try to get rid of the outliers. For example, you could try matlab's isoutlier function.
Since the signal to noise ratio looks very high, you could try fitting the circle directly without removing any of the outliers. There may be a file on the file exchange that fits a circle to a cluster of dots but avoid using circle-fitting algorithms that use least squares or that fit a circle according to dots along a circumference.
It may be helpful to see a distribution of point distances which may give you an approximate diameter estimate. pdist() would give you the distance between all points but it also may reach memory capacity since you have very many points.
You could also try a clustering technique. I wonder if kmeans() would be sufficient to find the center of the circle. Again, your SNR is very high so the outliers may not matter.
You might be able to use an image processing approach such as regionprops, too.
yonatan s
yonatan s le 23 Juin 2020
It's not perfect, but it seems isoutlier is the right approach.
pdist consumes too much memory.
I tried using some image processing tools, the problem is that axes change when transforming the plot to an image.
Thanks.
Adam Danz
Adam Danz le 23 Juin 2020
If you're still looking for a solution, attach the fig file containing the data, or attach a mat file containing the (x,y) coordinates.

Connectez-vous pour commenter.

Réponses (3)

Matt J
Matt J le 22 Juin 2020

1 vote

You could try using clusterdata to find the big concentration of points. Then minboundcircle from the File Exchange to get the radius,

1 commentaire

yonatan s
yonatan s le 23 Juin 2020
I have too many particles for that, it requires a lot of memory

Connectez-vous pour commenter.

darova
darova le 23 Juin 2020
Try density function hist3
r = rand(500,1)/5;
t = rand(500,1)*2*pi;
x = [rand(50,1); r.*cos(t)+0.5];
y = [rand(50,1); r.*sin(t)+0.5];
n = 20;
k = hist3([x y],[n n]);
k(k<2) = nan;
pcolor((0:n-1)/n,(0:n-1)/n,k)
hold on
plot(x,y,'.r')
hold off

4 commentaires

darova
darova le 23 Juin 2020
You can convert you data into an image and try imfindcircles
yonatan s
yonatan s le 23 Juin 2020
hist3 sounds like a good approach, but how would I get the radius of the circle out of it?
[centers,radii] = imfindcircles(A,radiusRange)
yonatan s
yonatan s le 23 Juin 2020
the axes change as I transform a plot to an image.

Connectez-vous pour commenter.

darova
darova le 24 Juin 2020

0 votes

Here is the idea
  • scale your data
  • create an image (fill pixels)
  • dilate image to create solid round object (circle)
  • use imfindcircles

5 commentaires

Matt J
Matt J le 24 Juin 2020
Modifié(e) : Matt J le 24 Juin 2020
And maybe also use bwareafilt to remove all but the biggest cluster of points.
darova
darova le 24 Juin 2020
No
Matt J
Matt J le 24 Juin 2020
Why not?
darova
darova le 25 Juin 2020
There is no need for it
yonatan s
yonatan s le 9 Juil 2020
Modifié(e) : yonatan s le 9 Juil 2020
Hi darova, went over it again. How do I scale the radius back? If I simply multiply it by the scaling factor it doesnt come out right.

Connectez-vous pour commenter.

Produits

Version

R2019b

Question posée :

le 22 Juin 2020

Modifié(e) :

le 9 Juil 2020

Community Treasure Hunt

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

Start Hunting!

Translated by