Question

I am using imagesc on my image1 with is a 2023 x 2023 pixel image.

figure(1)
imagesc(-1016:1015, -1016:1015, image1);

I am atempting to create a cartesian coordinate axis on the image, however the y-axis has range goes from negative to positive instead of positive to negative. I have tried a few different ways to fix the problem but nothing is working.

Tried:

imagesc(-1016:1015, 1016:-1015, image1);
imagesc(-1016:1015, 1016:-1:-1015, image1);
imagesc(-1016:1015, 1016:1:-1015, image1);
imagesc(-1016:1015, -(-1016:1015), image1);
set(gca,'YDir','reverse');

How do you reverse the scale on the y-axis using imagesc?

Was it helpful?

Solution 2

So the I had to do two things first I added a negative to the y-axis --> -(y-axis) and then I set the y-axis direction to normal. If I only did one the axis would look correct but the image was flipped across its horizontal midpoint.

figure(1)
imagesc(-1016:1015,-(-1016:1015),image1);
set(gca,'YDir','normal');

OTHER TIPS

By default, the imagesc function sets the YDir property to reverse. Try

set(gca,'YDir','normal');
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top