Flip image across Secondary Diagonal in MATLAB
Last Updated :
10 Apr, 2023
The aim is to flip a colored image in MATLAB across secondary diagonal without using inbuilt functions for rotating. A colored image can be represented as a 3 order matrix. The first order is for the rows, the second order is for the columns and the third order is for the layers, the pixel value will determine the color of the pixel based on the color format. Approach is very simple. We are given a colored image. We have to separate each layer. Flip every layer up to down then flip every layer right to left. Take transpose of the image. Below is the implementation:
matlab
I=imread( 'image.jpg' );
figure, imshow(uint8(I));
I2 = [];
for k = 1:3
Im = I(:, :, k);
Im1 = Im( end :-1:1, :);
Im2 = Im1(:, end :-1:1);
Im3 = Im2';
I2(:, :, k)=Im3;
end
figure, imshow(uint8(I2));
|
Input Image: Output :
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...