circle problem, circumscribed to another circle and the area, area per image detection
3 ビュー (過去 30 日間)
古いコメントを表示
I have been working on a transportation problem, I have a series of coordinates that always vary, but for this question let's suppose that I have 13 coordinates, each chord represents the center of a circle with a radius of 400m.
the circles are on an x, y plane. The idea is to find the total area that is inside each circle, the problem is that it is not simply multiplying the number of circles by (PI * R ^ 2), because many of them have 1 or more shared areas that do not they can be added more than once.
These circles may or may not intercept each other, through the program that I am designing, I even obtain the distance matrix between each one, at first I thought that the best way to solve the problem was mathematically, but today I realized that it is a problem of mathematical complexity .
So looking on the internet I found that more people have had a similar problem and that it can be solved analytically.
It turns out that there are people who say that the problem could be solved if each point is plotted on a 2d plane, then a 400 meter Buffet is placed at each point, each circle is painted in one color and then the background in another color.
Finally, an algorithm is required that is capable of finding the area that is colored, suppose that what is inside each circle is yellow and the outside is green.
could you please help me with this
attached document excel file
1)Once I have plotted the figure, how do I put the 400 meter buffer at each point, I know the x, y coordinate of each point)
2)Supposing that I manage to obtain a graph with the points and their respective buffer of 400 meters of radius, how I paint everything that is inside the buffer of the same color
3)how do i find the colored area inside each buffer
T=readtable('mini2.xlsx')
H = table(T.lon,T.lat);
plot(T.lon,T.lat,'ko*400')
plot It has no buffer, I don't know how to implement it
Thanks for your time.
examples:
I have read about the problem here : https://qastack.mx/programming/1667310/combined-area-of-overlapping-circles
3 件のコメント
Andrew
2021 年 8 月 26 日
編集済み: Andrew
2021 年 8 月 26 日
Are approximate answers OK? Since the radii are always 400 m, I would consider finding out ahead of time how much two circles overlap as a function of distance. At x/r~=0, the second circle has basically zero area, and at x/r~=2, it's basically a whole circle. Then you can simply pairwise see which ones overlap and apply the function. The only serious issue I see is that if you have three or more overlapping, you'll overcount the overlap, so I suppose this would work best if it's a pretty sparse map or the little bit in the midst of three circles doesn't matter much.
採用された回答
DGM
2021 年 7 月 23 日
編集済み: DGM
2021 年 7 月 23 日
This could be improved or elaborated, but it's a simple start:
% let's assume that 1px = 1 square meter
r = 400;
C = rand(10,2)*5000 + 1000; % test locations (x,y)
% get padded image size
p = 10; % extra padding
s = ceil([(max(C(:,2))-min(C(:,2))),(max(C(:,1))-min(C(:,1)))] + r*2 + p*2);
C = C - [min(C(:,1)) min(C(:,2))] + r + p; % shift image
% draw all circles
m = false(s);
for c = 1:size(C,1)
thisroi = images.roi.Circle('center',C(c,:),'radius',r);
m = m | createMask(thisroi,m);
end
totalarea = sum(m(:)) % total number of white pixels = area
imshow(m)
There is also bwarea(), but you might want to read the docs to make sure it's what you want. It's not the same as a simple sum.
Of course, if there are many such circles and they are very spread out, the image may be very large. It might be rather slow to do it by drawing circles like this. This is a different approach for the same thing, which should be faster than explicit circle drawing.
% same stuff
r = 400;
C = rand(10,2)*5000 + 1000; % test locations (x,y)
% same stuff
p = 10;
s = ceil([(max(C(:,2))-min(C(:,2))),(max(C(:,1))-min(C(:,1)))] + r*2 + p*2);
C = round(C - [min(C(:,1)) min(C(:,2))] + r + p);
% use distance xform
m = false(s);
m(sub2ind(s,C(:,2),C(:,1))) = 1;
m = bwdist(m)<=r;
totalarea = sum(m(:)) % total number of white pixels = area
imshow(m)
12 件のコメント
その他の回答 (2 件)
David Alejandro Ramirez Cajigas
2021 年 8 月 16 日
編集済み: David Alejandro Ramirez Cajigas
2021 年 8 月 17 日
3 件のコメント
DGM
2021 年 8 月 19 日
Oof. Sorry about that. Sometimes site notifications get buried, and I almost never check email anymore. Anyway...
% This is only part of the dataset!
lon = [-76.5249196 -76.5281573 -76.5278992 -76.5169571 -76.5322045 -76.5212801 -76.5212291 -76.5090573 -76.5304345 -76.5226856 -76.5180319 -76.5200061 -76.514478 -76.5121552 -76.5076382 -76.5074345 -76.5061631 -76.5059834 -76.5021961 -76.5019253 -76.5001202 -76.4916586 -76.4889863 -76.5249977 -76.5258832 -76.5285806 -76.5167687 -76.5141764 -76.5101736 -76.5053988 -76.4869869 -76.4909459 -76.4945159 -76.5327531 -76.5187478 -76.5101116 -76.5118256 -76.5368692 -76.5358927 -76.5351849 -76.5347021 -76.5364751 -76.5367191 -76.5355765 -76.5315237 -76.4893841 -76.5217632 -76.5215164 -76.5211731 -76.520905 -76.5205857 -76.5203818 -76.5180966 -76.5165489 -76.5165489 -76.5163424 -76.5147331 -76.5147384 -76.5163367 -76.517367 -76.5222486 -76.5227287 -76.523005 -76.5233778 -76.5015155 -76.4964618 -76.4980119 -76.5032478 -76.5232265 -76.5230613 -76.5206634 -76.5264623 -76.525545 -76.5272398 -76.528092 -76.5299112 -76.5320919 -76.5337575 -76.533956 -76.5346507 -76.5356673 -76.5365309 -76.5357638 -76.5348599 -76.5333472 -76.53415 -76.5281195 -76.5268189 -76.5293914 -76.5282836];
lat = [3.4310571 3.4330517 3.4329578 3.4259733 3.4141012 3.4132041 3.4147463 3.4200984 3.4193326 3.4191612 3.4195618 3.4194799 3.4197733 3.4199018 3.4191972 3.4186178 3.4172711 3.4174853 3.4131446 3.413158 3.410971 3.4120227 3.4146176 3.4187462 3.4121893 3.4266255 3.4291025 3.4347968 3.4321028 3.4271533 3.4185984 3.4218167 3.4248689 3.4282086 3.4354939 3.4334187 3.4352097 3.4277076 3.4309797 3.4333837 3.4349393 3.4327974 3.4182723 3.4090406 3.4077261 3.4109503 3.4086604 3.4107276 3.4166607 3.4197919 3.4226876 3.4247333 3.4252902 3.4295177 3.4295177 3.431641 3.434254 3.4347146 3.4324815 3.4213276 3.4175283 3.412915 3.410417 3.4071183 3.4253297 3.4339325 3.4309045 3.4244061 3.4351374 3.4346636 3.4352634 3.4330464 3.4329822 3.432503 3.431776 3.4305833 3.4284118 3.42642 3.4241897 3.4235712 3.4203582 3.4178333 3.4186983 3.4215123 3.4260317 3.431708 3.4312579 3.4321469 3.4104115 3.4129524];
lonlat = table(lon.',lat.');
% boundary
box = [-76.5369 3.4356; -76.4868 3.4071]; % lon/lat
% process table & box; convert to meters
lla = [fliplr(table2array(lonlat)) zeros(size(lonlat,1),1)];
position = lla2flat(lla,[min(lla(:,1)) min(lla(:,2))],90,0);
boxpos = lla2flat([fliplr(box) [0; 0]],[min(lla(:,1)) min(lla(:,2))],90,0);
boxpos = boxpos(:,1:2);
% same as before
r = 400;
C = position(:,1:2); % locations (x,y)
p = 10; % padding
s = ceil([(max(C(:,2))-min(C(:,2))),(max(C(:,1))-min(C(:,1)))] + r*2 + p*2);
refpoint = [min(C(:,1)) min(C(:,2))];
C = round(C - refpoint + r + p);
corners = round(boxpos - refpoint + r + p);
m = false(s);
m(sub2ind(s,C(:,2),C(:,1))) = 1;
m = bwdist(m)<=r;
m(:,[1:corners(1,1) corners(2,1):end]) = 0;
m([1:corners(1,2) corners(2,2):end],:) = 0;
size(C,1)*round(pi*r^2)
totalarea = sum(m(:)) % total number of white pixels = area
imshow(m); hold on
plot(corners([1 2 2 1 1],1),corners([1 1 2 2 1],2),':')
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!