question about imrotate function

2 ビュー (過去 30 日間)
UTA
UTA 2013 年 11 月 29 日
コメント済み: UTA 2013 年 11 月 29 日
When I use imrotate function to rotate a binary image which only has a single pixel with value of one, the rotate function I use as follow:
fimage = zeros(480,640);
fimage(140,396) = 1;
if 5.2668 < 90
fimage = imrotate(fimage, 5.2668,'crop');
elseif 5.2668 > 90
fimage = imrotate(fimage, 5.2668, 'crop');
end
where fimage is the image with size of 480*640 and with all value zero expect that single pixel, and the single value one pixel with the position of [140 396], however, the after rotating , I can not find that single value any more, which means the whole image becomes zero value. It seems that the rotate angle is not too large to make that value one pixel out of boundary, also that pixel almost lies in the center of the image, so it mean it should not be out of boundary and corp by that function. Can anyone help me on this?*
Thanks so much ahead.
  2 件のコメント
UTA
UTA 2013 年 11 月 29 日
it is very wired, I test many ange value from 1.2558 to 8.2668, only some value around 5.2668 can not show the rotate pixel.
Image Analyst
Image Analyst 2013 年 11 月 29 日
Like I tried to explain to you below, it depends on how close the input pixel is to its rotated position. If it's close, and the value would be more than 0.5 it rounds it up and you'll see it.

サインインしてコメントする。

採用された回答

Image Analyst
Image Analyst 2013 年 11 月 29 日
There is no pixel at the center of an image that has an even number of rows or columns. Thus your pixel landed at some place in between 4 pixels. When averaged with the 3 other black pixels (to create the output pixel), your pixel ended up being less than 1. They 4 corners averaged 0.25 and since your output is binary, it rounded down to 0 and disappeared. You can make it grayscale if you want to keep it.
  2 件のコメント
Image Analyst
Image Analyst 2013 年 11 月 29 日
Try using the 'nearest' option to prevent anti-aliasing and rounding.
UTA
UTA 2013 年 11 月 29 日
thank you, it's helpful.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAxes Transformations についてさらに検索

タグ

タグが未入力です。

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by