To rotate an image clockwise by 90 degrees using permute
and fliplr
, you can follow the steps below:
imread
function.permute
function to swap the rows and columns.fliplr
function to flip the transposed image from left to right.imshow
function.Here's the code implementing the above steps:
main.m193 chars9 lines
Note that we permute the dimensions of the image using [2 1 3]
so that the columns become rows and rows become columns, and the third dimension (RGB) remains unchanged. Finally, we flip the result along the horizontal axis (left to right) with fliplr
to get the desired clockwise rotation.
gistlibby LogSnag