The four-element position vector using getPosition returns double values rather than integers.
7 次查看(过去 30 天)
显示 更早的评论
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.
回答(2 个)
Azzi Abdelmalek
2012-8-25
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 个评论
Ramaprasad Kulkarni
2012-8-27
2 个评论
Walter Roberson
2012-8-27
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.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!