Bounded Area
조회 수: 15 (최근 30일)
이전 댓글 표시
Hi, I am trying to create a bounded area using two separate sets of points. One set will create the upper bound and the other will create the lower bound. I am new to MATLAB so am lost. Does anyone have any suggestions?
댓글 수: 6
the cyclist
2012년 2월 21일
Kylie, have you tried running the convex hull (not convex "hole") code that I put in my solution? That illustrates the concept. It is essentially the "bounded area" that you are talking about. A more technical definition is here: http://mathworld.wolfram.com/ConvexHull.html
답변 (2개)
the cyclist
2012년 2월 21일
Please do follow the suggestion in Sean's comment. But taking a guess here, I think the convhull() function might be useful for what you are trying to do. Here is an example from the help file:
x = rand(20,1);
y = rand(20,1);
figure
hold on
plot(x,y, '.');
k = convhull(x,y);
plot(x(k), y(k), '-r')
hold off
댓글 수: 0
Image Analyst
2012년 2월 22일
I'm not sure what "upper" and "lower" refer to but maybe she's wanting to combine two areas, and not necessarily in a convex hull manner. Maybe she just want to OR two binary regions together using poly2mask(), as in this code:
clc; % Clear the command window.
workspace; % Make sure the workspace panel is showing.
fontSize = 20;
b = zeros(500, 'uint8');
subplot(2,2,1);
imshow(b);
axis on;
title('Draw a polygon', 'FontSize', fontSize);
% Enlarge figure to full screen.
set(gcf, 'units','normalized','outerposition',[0 0 1 1]); % Maximize figure.
message = sprintf('Draw the first polygon with left clicks.\nRight click on the final vertex to finish it');
uiwait(msgbox(message));
% Draw the first polygon.
bw1 = roipolyold();
imshow(bw1);
axis on;
title('First polygon', 'FontSize', fontSize);
message = sprintf('Draw the second polygon with left clicks.\nRight click on the final vertex to finish it');
uiwait(msgbox(message));
% Draw the second polygon.
bw2 = roipolyold();
subplot(2,2,2);
imshow(bw2);
axis on;
title('Second polygon', 'FontSize', fontSize);
% Combine them with OR.
both = bw1|bw2;
subplot(2,3,5);
imshow(both);
axis on;
title('Both polygons', 'FontSize', fontSize);
참고 항목
카테고리
Help Center 및 File Exchange에서 Computational Geometry에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!