MATLAB: How to reverse the y-axis when I use the IMAGE or IMAGESC function to display an image in MATLAB

imagescMATLABreversey axis

I execute the following commands to display an image using the IMAGESC function:
load clown
clims = [10 60];
imagesc(X,clims)
colormap(gray)
The y-axis runs from the top of the image to the bottom. I would like to reverse the y-axis so that it starts at the bottom of the image and runs to to the top.

Best Answer

This change has been incorporated into the documentation in Release 2009b (R2009b). For previous releases, read below for any additional information:
The first row of pixels is normally at the top of an image. By default, the IMAGE and IMAGESC functions invert the y-axis direction when the image is displayed on an axes by setting the 'YDir' property to 'reverse.' To invert the y-axis direction, set the 'YDir' property to 'normal', as follows:
load clown
clims = [10 60];
imagesc(flipud(X),clims)
colormap(gray)
set(gca,'YDir','normal')