The four-element position vector using getPosition returns double values rather than integers.
7 views (last 30 days)
Show older comments
Hi everyone,
The four-element position vector returned after selecting rectangle or ellipse or other shapes in an image as a result of imrect, imellipse functions using getPosition function is of type double. When the first two elements represent the coordinates of the top left corner of the rectangle and the next two elements represent the width and height of the rectangle, all the four values are expected to be integers because the image is discrete and the values are in units of 'number of pixels' (I assume).
It does not make sense for the coordinates or width and height to be double. Can anyone explain the reason for the vector to have double values, which means that it is giving us sub-pixel accuracy ?
-- Thanks in advance, Ram.
Answers (2)
Azzi Abdelmalek
on 25 Aug 2012
imshow('pout.tif');
h = imrect;
position = wait(h);
% the result is double but without decimals. if you want the result to be integer
position = uint32(position);
0 Comments
Ramaprasad Kulkarni
on 27 Aug 2012
2 Comments
Walter Roberson
on 27 Aug 2012
What Units are you using? The Position is possibly being stored in a different unit than you are using, resulting in a non-integral value when you examine it.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!