I'm trying to crop an image but not with a rectangle (like in imcrop()
) but with a polygon that has four corners. I've searched a lot and discovered that I need to perform a homography to reajust the cropped polygon into a rectangle.
So I've used imcrop()
to select a polygon in an image :
img = imread('pout.tif');
imshow(img);
h = impoly;
position = wait(h);
x1 = min(position(:, 1));
x2 = max(position(:, 1));
y1 = min(position(:, 2));
y2 = max(position(:, 2));
BW = createMask(h);
How could I use these two things to crop out an area in the shape of a polygon with four corners ?