1

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 (only the first frame, kin the code below).

I would like to be able to draw a slanted rectangles too. Is there any command that can help me?

 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
1
  • what do you mean slanted rectangles? do you mean just any Parallelogram? or only ones where the base is parallel to the X axis? how would you expect the slanted rectangles to be represented numerically? you might try mipoly.
    – pseudoDust
    Sep 12, 2013 at 11:34

1 Answer 1

0

In your code, imrect is responsible for drawing a rectangle.

You may use impoly to draw some polygons (here slanted rectangles).

The code

imshow('cameraman.tif')
h_poly = impoly;

will give

enter image description here

You can modify the shape by drag/dropping the selection's blue handles.

The positions of the blue handles can be known with

pos = getPosition(h_poly) 
3
  • Hi,the impoly function does work but i can't understand hoe i can get the position of the polys i draw.When it gets to the line of the position it returns an error: "Subscripted assignment dimension mismatch."
    – Maayan
    Sep 15, 2013 at 7:09
  • please see the edit - in a for loop, you may declare pos{i} = getPosition(h_poly).
    – marsei
    Sep 15, 2013 at 8:12
  • Hi, is there any way to be certain that my polygon is a rectangle? When i draw my polygon, with the impoly() command, i'm not straight enough and i get an abstract form. I really need it to be a rectangle.
    – Maayan
    Sep 15, 2013 at 11:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.