imrotate make image blur. Any solution?
3 views (last 30 days)
Show older comments
I = imread('cameraman.tif');
L = imrotate(I,50);
M= imrotate(L,-50);
imshow(M)
x_corr = normxcorr2(I,M);
[max_c, imax] = max(abs(x_corr(:)))
I tested with above code to see the effect of imrotate had on image. The result if the correlation was 0.94, less than what i expected and the image M was blur.
Any way to rotate the image without effecting its pixel value?
Thanks
0 Comments
Accepted Answer
Kyle
on 7 Jun 2011
1 Comment
Walter Roberson
on 7 Jun 2011
In order to preserve pixel values, your rotated picture would have to contain the same number of lit pixels as the original picture, and you would have to come up with a one-to-one and "onto" mapping of the pixels that worked for any rotation angle. This is not necessarily impossible, but the variations that I can think of at the moment have the effect of having pictures that are not aligned with the axes be non-square.
I suggest you start with a simple case: rotate a single-width line from the axes to 45 degrees. Which pixels would you choose to light in the rotated image? What is the distance from the origin of rotation to the edge of the lit area? Were you able to come up with a fixed pixel mapping that pretty much preserved linear distances? Okay, now extend this to a line of width two being rotated to 45 degrees and see if you find that the choices you made for where to put the pixels for the first line clash with where the pixels would go for the second line.
More Answers (1)
Walter Roberson
on 5 Jun 2011
No, the closest you can get to rotating an image without affecting its pixel value is to use a hgtransform -- which will affect the pixels of the displayed image but not the values that are stored in the CData property of the image. The observed image will have blur either way. This is inherent in the representation of data as finite sized non-circular pixels.
1 Comment
Jan
on 6 Jun 2011
+1. The blur is a result of the rotation of a data, which are discretized in rectangles (pixels here). Imagine a 2x2 pixel image: a rotated image *must* be blurred, of course.
You can reduce the effects by increasing the resolution before rotating and decreasing it afterwards again - this is an anti-aliasing method and the Lanczos3 method might be "nice". But unfortunately this will produce other artifacts.
See Also
Categories
Find more on Geometric Transformation and Image Registration in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!