How can I find exactly the coordinates of the center of the yellow circle?
3 次查看(过去 30 天)
显示 更早的评论
Hi everybody,
maybe my problem is stupid, but I need your help. I need to find exactly the center of the yellow circle in my image. It's an electromagnetic field distribution and I need to know whwre is centered, because it's not in the center of the image. Is there a way to find it out? I'm working with a 601x601x13 double matrix, I plotted the distribution at a certain height along the Z axis. Thanks to anyone who will give me a hand.
4 个评论
采纳的回答
Walter Roberson
2021-5-15
编辑:Image Analyst
2021-5-15
You can calculate the center of mass of the image.
7 个评论
Walter Roberson
2021-5-16
Experimenting:
format long g
rvec = linspace(-5,5,100);
cvec = linspace(-5,5,100);
[r, c] = ndgrid(rvec, cvec);
actual_center = randn(1,2)
A = 10 .* exp(-(r-actual_center(1)).^2/2) .* exp(-(c-actual_center(2)).^2/2);
pcolor(r, c, A)
ideal_array_r = interp1(rvec, 1:length(rvec), actual_center(1))
ideal_array_c = interp1(cvec, 1:length(cvec), actual_center(2))
tot_mass = sum(A(:));
[ii,jj] = ndgrid(1:size(A,1),1:size(A,2));
R = sum(ii(:).*A(:))/tot_mass;
C = sum(jj(:).*A(:))/tot_mass;
out = [tot_mass,R,C]
calculated_array_r = R
calcualted_array_c = C
So that is actual 61.5628526804514 versus calculated 61.5608654718254 and actual 26.4853227796535 versus calculated 26.6115951119575
Accuracy in the first case was about 1/100 which is less than 1 / number of bins in that direction.
Accuracy in the second case was about 13/100 which is notably less precise.
This hints that the accuracy can depend upon how close to the edge of the image that you are, in cases where data is being effectively truncated. This makes sense from a mathematical perspective.
更多回答(2 个)
Rakesh Das
2021-5-15
circle is (x – h)2+ (y – k)2 = r2, where (h, k) represents the coordinates of the center of the circle, and r represents the radius of the circle. If a circle is tangent to the x-axis at (3,0), this means it touches the x-axis at that point. this is the concept of obtating the coordinates of yellow circle.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Number Theory 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!