How to rotate an image by 225 degrees but still fill up the space entirely, rather than leave edges blackened.
2 views (last 30 days)
Show older comments
I am trying to rotate the Gimage by 225 so that it looks like the picture displayed below, however, using the permute or imrotate function rotates the picture but it leaves the top, bottom and both sides blackened. Is there an easy fix to this? Is there a way to fix this using a for loop? I tried the for loop but couldn't figure out a result. I have been stuck on this for a few hours and I'm beginning to get frusterated. Note this is not hw. I am simply trying to learn the matlab program
Bimage = zeros(256, 256, 1, 'uint8');
Bimage(:, :, 3) = repmat(255:-1:0, 256, 1);
Bimage=Bimage(:,:,3);
imagesc(Bimage)
Gimage = zeros(256, 256, 1, 'uint8');
Gimage(:, :, 2) = repmat(0:1:255, 256, 1);
G2=permute(Gimage,[2 1 3]); %Rotate image by 90 degrees
G2=G2(:,:,2);
imagesc(G2)
Rimage = zeros(256, 256, 1, 'uint8');
Rimage(:, :, 1) = repmat(0:1:255, 256, 1);
R2=imrotate(Rimage,90); %Rotate image by 90 degrees
R2=R2(:,:,1);
imagesc(R2)
subplot(2,2,1), imshow(Bimage); title('Blue Image');
subplot(2,2,2), imshow(G2); title('Green Image');
subplot(2,2,3), imshow(R2); title('Red Image');
subplot(2,2,4), imshow(cat(3,Bimage,G2,R2)); title('Rainbow Image');

0 Comments
Answers (1)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!