How to draw vertical line and a horizontal line passing from the centroid of a region?
古いコメントを表示
How to draw vertical line and a horizontal line passing from the centroid of a region?The horizontal and vertical line should be inside the region only.I also want to find the length of the lines.Please help me.

2 件のコメント
Andrew Newell
2014 年 2 月 22 日
What information do you have? A set of points or an equation?
Naishil shah
2014 年 2 月 23 日
採用された回答
その他の回答 (3 件)
Dishant Arora
2014 年 2 月 22 日
編集済み: Dishant Arora
2014 年 2 月 22 日
doc line
I guess you have information about centroid and boundary points.
2 件のコメント
Naishil shah
2014 年 2 月 22 日
Image Analyst
2014 年 2 月 22 日
編集済み: Image Analyst
2014 年 2 月 22 日
So, is this solved or not? If so, mark it Accepted. If not, look at my Image Segmentation Tutorial to learn how to find centroids and boundary points. http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862 If you still need help after that, let me know. It's a lot easier to find vertical and horizontal bisectors than bisectors that go along the major and minor axes (if the blob is not aligned with the edges of the image), so you're lucky you want the easy way.
Star Strider
2014 年 2 月 22 日
My suggestion:
elps = @(a,b,c,d,t) [c+a.*cos(t); d+b.*sin(t)];
a = 0.13; b = 0.77; c = 3.12; d = 5.17;
t = 0:0.1:2*pi;
pts = elps(a,b,c,d,t); % Generate ellipse
endpts = [min(pts,[],2) max(pts,[],2)] % Limits of x, y
mxy = mean(pts,2); % Determine centroid
figure(1)
plot(pts(1,:),pts(2,:), 'b*')
hold on
plot(endpts(1,:), [1 1]*mxy(2), '-r') % Plot first axis in red
plot([1 1]*mxy(1), endpts(2,:), '-g') % plot second axis in green
hold off
grid
2 件のコメント
Naishil shah
2014 年 2 月 23 日
Image Analyst
2014 年 2 月 23 日
You still couldn't figure it out even after running my tutorial? OK, I'll try to see if I can adapt it for you if I get time later this afternoon.
Dalila FEKRACHE
2016 年 1 月 22 日
0 投票
Good morning, After drawing vertical line and a horizontal line passing from the centroid of a region, How can i calculate the areas in each side of the two axis ?? Please help me
1 件のコメント
Image Analyst
2016 年 1 月 22 日
Is the line really vertical and horizontal, or is it at an angle long the major axis? Maybe you should start your own question and attach your image.
カテゴリ
ヘルプ センター および File Exchange で Display 2-D Images についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

