Flip image across Secondary Diagonal in MATLAB
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 code to flip a colored image % across secondary diagonal. % Read a colored image I=imread('image.jpg'); figure, imshow(uint8(I)); % Initilase an image I2 = []; %iterate each layer for k = 1:3 Im = I(:, :, k); %Flip every layer up to down. Im1 = Im(end:-1:1, :); %Flip every layer right to left. Im2 = Im1(:, end:-1:1); %Take transpose of the image. Im3 = Im2'; I2(:, :, k)=Im3; end % Show the image. figure, imshow(uint8(I2)); |
Input Image:

Output :

Recommended Posts:
- MATLAB | Converting a Grayscale Image to Binary Image using Thresholding
- MATLAB | RGB image to grayscale image conversion
- Matlab | Erosion of an Image
- Matlab | Dilation of an Image
- MATLAB | RGB image representation
- Image Resizing in Matlab
- Image Complement in Matlab
- Extract bit planes from an Image in Matlab
- LSB based Image steganography using MATLAB
- MATLAB | Complement colors in RGB Image
- MATLAB | Display histogram of a grayscale Image
- Image Processing in MATLAB | Fundamental Operations
- MATLAB | Complement colors in a Grayscale Image
- MATLAB | Complement colors in a Binary image
- Matlab | Edge Detection of an image without using in-built function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



