Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
geometrical distortion - rotation

Subject: geometrical distortion - rotation

From: PANDIAN` NITHYANANDAM

Date: 26 Nov, 2011 17:57:08

Message: 1 of 6

hai matlab expert

i have one problem, kindly try to understand what i stay.

assume original image : A
rotated image : B

i has an bmp image (A) which is 256 X 256. i rotated the image (B) to 90 degree.
in the rotated image (B), i can find out the pixel intensity of every element of original image in the followig order.

original image pixel position(A) rotated image (90) pixel position (B)
1,1 shifted to 1,256
1,256 shifted to 256,256
256,1 shifted to 1,1
256,256 shifted to 1,256

the dimesion 256 x 256 remains the same in image B too.

this is true for angle such as 180 and 270 degree too. only the position get shifted correspondingly for the appropriate degree.
 But however i can find all the pixels in the original image(A) in some where in B.
---------------------------

now the question starts???????????

i rotated the same image (A) to 1 degree . Now in the rotated image (B), i am unable to find A's pixle content in B, which i found exactly all the pixels somewhere in the case of 90,180 and 270 degree rotation.

in this case the image size also increased by 261 X 261. (B)

this is ideal for all the degree except 90,180 and 270. The image size is increased by on an average 4 -10 rows and columns.

why this is so? why i could not locate the original image (A) pixel in n degree (except 90,180,270) rotated image (B).

what is actually happening? If i could find my pixel in 90,180,270 degree case, why not in other angles?????


can anyone give clarifcation regarding this.

if any one want to have more light and explanation on this, kindly feel freee to contact me at nithyanandamp@ssn.edu.in


---------------

the file i used is 256 X 256 grayscale lena image.

the coding is used is

a=imread('orgi.bmp');
b=imrotate(a,-90,'nearest');

this is working fine


whereas the following creating problem

a=imread('orgi.bmp');
b=imrotate(a,-1,'nearest');


help is appreciated.


thanks

Subject: geometrical distortion - rotation

From: Matt J

Date: 26 Nov, 2011 20:19:08

Message: 2 of 6

"PANDIAN` NITHYANANDAM" <nithyanandamp@ssn.edulin> wrote in message <jar99k$8gu$1@newscl01ah.mathworks.com>...
>
> in this case the image size also increased by 261 X 261. (B)
>
> this is ideal for all the degree except 90,180 and 270. The image size is increased by on an average 4 -10 rows and columns.
>
> why this is so?
===============

You can force B to be the same size as A if you use imrotate's 'crop' option. This isn't always what you want, though, because a rotated object may need a larger rectangular grid to be fully displayed. Try rotating a chess board 45 degrees and then draw the tightest unrotated square boundary around it that you can. You'll see that it's larger than the unrotated chess board.

 
> what is actually happening? If i could find my pixel in 90,180,270 degree case, why not in other angles?????
========


Because when you rotate an integer pixel coordinate (i,j) by an angle that is not 90,180,270 it will rotate to a non-integer coordinate (x,y).
IMROTATE has to interpolate the pixels neighbouring (x,y) to come up with a reasonable intensity value.

Subject: geometrical distortion - rotation

From: Matt J

Date: 26 Nov, 2011 20:29:08

Message: 3 of 6

"PANDIAN` NITHYANANDAM" <nithyanandamp@ssn.edulin> wrote in message <jar99k$8gu$1@newscl01ah.mathworks.com>...
>>
> whereas the following creating problem
>
> a=imread('orgi.bmp');
> b=imrotate(a,-1,'nearest');
>
========

And doing 'nearest' neighbor interpolation won't help. The transformation is non-invertible.

Subject: geometrical distortion - rotation

From: PANDIAN` NITHYANANDAM

Date: 27 Nov, 2011 17:51:08

Message: 4 of 6

"Matt J" wrote in message <jarhjs$1hg$1@newscl01ah.mathworks.com>...
> "PANDIAN` NITHYANANDAM" <nithyanandamp@ssn.edulin> wrote in message <jar99k$8gu$1@newscl01ah.mathworks.com>...
> >
> > in this case the image size also increased by 261 X 261. (B)
> >
> > this is ideal for all the degree except 90,180 and 270. The image size is increased by on an average 4 -10 rows and columns.
> >
> > why this is so?
> ===============
>
> You can force B to be the same size as A if you use imrotate's 'crop' option. This isn't always what you want, though, because a rotated object may need a larger rectangular grid to be fully displayed. Try rotating a chess board 45 degrees and then draw the tightest unrotated square boundary around it that you can. You'll see that it's larger than the unrotated chess board.
>
>
> > what is actually happening? If i could find my pixel in 90,180,270 degree case, why not in other angles?????
> ========
>
>
> Because when you rotate an integer pixel coordinate (i,j) by an angle that is not 90,180,270 it will rotate to a non-integer coordinate (x,y).
> IMROTATE has to interpolate the pixels neighbouring (x,y) to come up with a reasonable intensity value.


why it has to interpolate for the degrees other than 90,180 and 270.

why specifically interpolation for 1, 2,3,4,...359 degrees.

i checked the interpolation done in all the three methods, such as nearest neighbor, bilinear, bicubic. The pixel intensities remains the same.

can you throw light on this.

help appreciated.

Subject: geometrical distortion - rotation

From: Matt J

Date: 27 Nov, 2011 18:24:08

Message: 5 of 6

"PANDIAN` NITHYANANDAM" <nithyanandamp@ssn.edulin> wrote in message <jattac$st5$1@newscl01ah.mathworks.com>...
>
>
>
> why it has to interpolate for the degrees other than 90,180 and 270.
>
> why specifically interpolation for 1, 2,3,4,...359 degrees.
======================

As Bruno told you in your other post, interpolation _always_ occurs even at 90,180,270 degrees. It's true that there is no loss due to the interpolation at these special angles but that's only because the rotated coordinates coincide with integer pixel locations. When you interpolate at integer pixel locations, the interpolation reproduces the values at those locations (for all typical interpolators).

When the rotated coordinates land in between the integer pixel locations however, it is hard to predict what the new values will be or whether the process will be reversible.



> i checked the interpolation done in all the three methods, such as nearest neighbor, bilinear, bicubic. The pixel intensities remains the same.
==========

Not in general. Here's an example where none of the original pixel values remain the same:
 
>> imrotate(eye(4),10,'bilinear')

ans =

    0.1607 0.0491 0 0 0
    0.5858 0.4402 0.1681 0 0
         0 0.3471 0.5000 0.3471 0
         0 0 0.1681 0.4402 0.5858
         0 0 0 0.0491 0.1607

Subject: geometrical distortion - rotation

From: Matt J

Date: 27 Nov, 2011 19:52:08

Message: 6 of 6

"Matt J" wrote in message <jatv88$4vq$1@newscl01ah.mathworks.com>...
> "PANDIAN` NITHYANANDAM" <nithyanandamp@ssn.edulin> wrote in message >
>
> why specifically interpolation for 1, 2,3,4,...359 degrees.
> ======================
>
> As Bruno told you in your other post, interpolation _always_ occurs even at 90,180,270 degrees.
================

That's not true, as I've now discovered.
But the only reason IMROTATE doesn't interpolate at those angles is that it doesn't need to. The same resampling is doable by a trivial shuffling of the origingal pixel values.

 

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us