フィルターのクリア

how to draw border

12 ビュー (過去 30 日間)
mohd
mohd 2012 年 4 月 27 日
hi there, i have four set of coordinate and i want to draw line to make a border. after that i want to crop it automatically at the border. here, i attach the illustration for further understanding. please help me.. thank you
  2 件のコメント
Thomas
Thomas 2012 年 4 月 27 日
are you performing these operation on an image, or are you actually plotting the points?
mohd
mohd 2012 年 4 月 27 日
i'm performing these operation on image.. sorry.. i'm forget to tell us

サインインしてコメントする。

採用された回答

Thomas
Thomas 2012 年 4 月 27 日
Since you are performing your operations on an image
I'm assuming you know the coordinates and size of the rectangle you want..
I1=imread('myimage.jpg'); % import your image
%the following step is not necessary but just shows the boundary box..
imshow(I1);
hold on
w=[26 77];
x=[26 555];
y=[426 77];
z=[426 555];
Points = [w;x;z;y;w]; %in desired order
plot( Points(:,1), Points(:,2), 'r-'); % draw bounding box
hold off;
figure
I2=imcrop(I1,[26 77 400 478]) % crop the bounding box
imshow(I2) % show cropped image
  4 件のコメント
Thomas
Thomas 2012 年 4 月 27 日
that is the size of the rectangle 426-26=400(width) and 555-77=428(length)
mohd
mohd 2012 年 4 月 27 日
ok.. thanks:). yes, really understand. :)

サインインしてコメントする。

その他の回答 (1 件)

Matt Kindig
Matt Kindig 2012 年 4 月 27 日
To draw the border, you can just use 'plot':
w=[26 77];
x=[26 555];
y=[426 77];
z=[426 555];
Points = [w;x;z;y;w]; %in desired order
plot( Points(:,1), Points(:,2), 'r-');
What do you mean you want to "crop" your data set at the border?
  2 件のコメント
Thomas
Thomas 2012 年 4 月 27 日
I guess the user means to say only see the boxed area in the plot..
In that case add the following line to the code
set(gca,'xlim',[min(Points(:,1)) max(Points(:,1))],'ylim',[min(Points(:,2)) max(Points(:,2))])
mohd
mohd 2012 年 4 月 27 日
i mean i want to crop image at border. here attach the illustration. after make border and i want to crop as in my attachment.
http://i1259.photobucket.com/albums/ii548/msaiful89/crop.png
i hope you can understand what i mean..:) anyway.. thank a lot for helping me..:)

サインインしてコメントする。

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by