Question

I have an image (2D) of size 100 x 100 pixels. I display it using imagesc. This renders the image with x and y axes ranging from 1-100. However, instead of displaying the axes in pixel terms, I want the axes to refer to something real, in my case distance. So, I want the 1-100 values to now read 1-10 mm, since for me, each pixel corresponds to 0.1mm distance.

How do I do this? I tried xlim, ylim. But they only crop my image from 1-100 down to 1-10.

Was it helpful?

Solution

You could try this

I = rand(100, 100);
imagesc(1:10, 1:10, I)
xlabel('mm')
ylabel('mm')

The output is

enter image description here

OTHER TIPS

I = rand(100, 100);
imagesc(I);
set(gca,'xtick',10:10:100,'xticklabel',{'1mm','2mm','3mm','4mm','5mm','6mm','7mm','8mm','9mm','10mm'});
set(gca,'ytick',10:10:100,'yticklabel',{'1mm','2mm','3mm','4mm','5mm','6mm','7mm','8mm','9mm','10mm'});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top