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!