MATLAB: How can i draw a slanted rectangle in a frame

graphicsimage processingvideo processing

I have a code that takes a video,split it into frames and then asks me how many rectangles would i like to draw on the frame (the first one). In those rectangles the mean intensity in each frame is calculated.I would like to be able to draw a slanted rectangles too.Is there any command that can help me?Here is the part of my code that is responsible for making the rectangles:
if k==1
result=input('How many rectangles would you like to draw? ');
pos=zeros(result,4);
for i=1:result
handle=imrect;
pos(i,:)=handle.getPosition;
end
end

Best Answer

You could call the line() command 4 times to draw the sides of your slanted rectangle in the graphical overlay above the image. Alternatively, if the user needs to adjust the vertices, you can call impoly().
Related Question