question about imrotate function

4 vues (au cours des 30 derniers jours)
UTA
UTA le 29 Nov 2013
Commenté : UTA le 29 Nov 2013
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 commentaires
UTA
UTA le 29 Nov 2013
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 le 29 Nov 2013
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.

Connectez-vous pour commenter.

Réponse acceptée

Image Analyst
Image Analyst le 29 Nov 2013
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 commentaires
Image Analyst
Image Analyst le 29 Nov 2013
Try using the 'nearest' option to prevent anti-aliasing and rounding.
UTA
UTA le 29 Nov 2013
thank you, it's helpful.

Connectez-vous pour commenter.

Plus de réponses (0)

Tags

Aucun tag saisi pour le moment.

Community Treasure Hunt

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

Start Hunting!

Translated by