# rotating a matrix without interpolation

3 views (last 30 days)

Show older comments

Hey,

I want to rotate a mtrix by a certain degree without interpolating the intermediate pixels and just place NaN in them.

I tried to use imrotate but there is no option to do it without interpolating.

Any suggestions?

Thank in advence.

Oded

##### 0 Comments

### Answers (1)

Walter Roberson
on 2 Dec 2020

When you rotate a matrix, then the only pixels that can be calculated without any interpolation are the ones whose coordinates are such that the ratio of coordinates is exactly an integer multiple of tan() of the rotation angle. For example if the rotation is 42.7093899573615 degrees then there are some pixels whose coordinates happen to fall on the famous (5, 12, 13) pythagorean triple, and those single pixels could be copied without any interpolation. Every other pixel would require interpolation.

Are you sure you want to construct a matrix of nan that is the appropriate size to hold the rotated matrix, with the entire matrix nan except for the few scattered pixels that just happen to be at exactly the right coordinates to be carried from integer position to integer position by the rotation?

##### 7 Comments

Walter Roberson
on 5 Dec 2020

### See Also

### Community Treasure Hunt

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

Start Hunting!