Image is rotating but becoming whitish!
8 views (last 30 days)
Show older comments
I am trying to rotate the image without using imrotate. Logic is fine and image is rotating as well. But image is getting noise or something and becoming whitish. Any help would be appreciated as I am a beginner in this. Thank you.
% Read input image
img = imread('dog.jpeg');
img_90 = rotate90(img);
img_180 = rotate90(img_90);
% display result
subplot(1, 3, 1), imshow(img), title('Original Image');
subplot(1, 3, 2), imshow(img_90), title('Rotated (90)');
subplot(1, 3, 3), imshow(img_180), title('Rotated (180)');
function rotated = rotate90(img)
[r, c, z] = size(img);
% Create dummy matrix to store updated matrix.
rotated(c, r, z) = 0;
% Loop to access each element of matrix.
for plane = 1:z
for i = 1:r
for j = 1:c
% Logic to rotate Matrix A by 90 degree.
rotated(c-(j-1), i, plane) = img(i, j, plane);
end
end
end
end

0 Comments
Accepted Answer
More Answers (0)
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!