필터 지우기
필터 지우기

How to fit a trapezium or a square or an ellipse around this? Is there any way ?

조회 수: 10 (최근 30일)
L K
L K 2017년 2월 2일
댓글: KSSV 2017년 2월 2일
  댓글 수: 2
KSSV
KSSV 2017년 2월 2일
Where you want to fit? question is not clear. You want to fit on the attached image?
L K
L K 2017년 2월 2일
yes on the attached image... suppose if i have a set of points and i have already fitted a curve around it...
like for example in the image shown,if you see there is already an ellipse kind of around those points...so now i want to fit a square or a trapezium around the ellipse

댓글을 달려면 로그인하십시오.

답변 (1개)

KSSV
KSSV 2017년 2월 2일
clear all ;
data = imread('fit.png') ;
h1 = axes ;
image([0 1], [0 1],data);
hold on
%%draw square
P = ginput(4) ;
pts = [P ; P(1,:)] ;
plot(pts(:,1),pts(:,2),'k') ;
click at the points you want to draw square/ trapezium or rectangle when cross is popped out.
  댓글 수: 2
L K
L K 2017년 2월 2일
편집: KSSV 2017년 2월 2일
by saying on attached image i meant ,i have plotted a similar curve...
heres the code
x=0:1:20;
y = abs(sqrt(x));
%[xx,yy] = pol2cart(x,y);
k = convhull(x, y);
xch = x(k);
ych = y(k);
%[xCH, yCH] = cart2pol(xch, ych);
plot(xch, ych, 'ro-',x,y,'b*');
and i want to give a boundary like a square /trapezium around this envelope...
KSSV
KSSV 2017년 2월 2일
When you have the data in hand it shall be more easy to plot what you want.
clc
clear all ;
x=0:1:20;
y = abs(sqrt(x));
%[xx,yy] = pol2cart(x,y);
k = convhull(x, y);
xch = x(k);
ych = y(k);
%[xCH, yCH] = cart2pol(xch, ych);
plot(xch, ych, 'ro-',x,y,'b*');
x0 = min(x) ; x1 = max(x) ;
y0 = min(y) ; y1 = max(y) ;
%%square
pts = [x0 y0 ; x0 y1 ; x1 y1 ; x1 y0 ; x0 y0] ;
hold on
plot(pts(:,1),pts(:,2),'r')
%%circel
c0 = 0.5*[x0+x1 y0+y1] ;
R = 10 ;
th = linspace(0,2*pi) ;
xc = c0(1)+R*cos(th) ;
yc = c0(2)+R*sin(th) ;
plot(xc,yc,'r')
axis equal

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Surfaces and Volumes에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by