How to set the default corner for origo in imagesc?
Show older comments
I would like to use origo in the bottom-left corner as mathematicians used to.
Answers (2)
Geoff Hayes
on 14 Nov 2014
Merse - do you just want to reverse the order of the y-axis so that zero (along y) is in the bottom left corner? Or do you want to be able to manipulate the data in the image given that new ordering? If just the former, then you could do
% get the handle to the image
hImg = imagesc(...);
% get the handle to the parent axes
hAxs = get(hImg,'Parent');
% reverse the order of the y-axis tick labels
yAxisTickLabels = get(hAxs, 'YTickLabel');
set(hAxs,'YTickLabel',flipud(yAxisTickLabels));
The above code just flips the y-axis tick labels so that their order is reversed. NOTE that this does not change the manner in which you can access the data in the image, all it does is flip the labels.
Image Analyst
on 9 Jun 2022
By default, images use
axis ij
which puts the (1,1) location at the upper left as is the convention for arrays and images. If you want it at the lower left, like an (x,y) plot use
axis xy;
3 Comments
Giammarco Nalin
on 29 Mar 2023
where should I put this modifcation?
Image Analyst
on 29 Mar 2023
After you call plot(), image(), imshow(), or imagesc().
Louis
on 24 Jan 2024
thank you, you are a boss
Categories
Find more on Image Arithmetic in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!