MATLAB: How to draw border

borberbordercoordinatecroppoints

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

Best Answer

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