MATLAB: How to convert matrix to graysclae image

displayimagematrix manipulation

Hi, I have a matrix that i have extacted using spin images descriptor, it is of size 15×15 :
I want to display it in gray scale but it doesn't work. I tried to use imshow() like this :
imshow(uint8(spinImages(1,1).spinIm),'DisplayRange',[0 255])
imshow(255-uint8(spinImages(1,1).spinIm),'DisplayRange',[0 255])
and also i used imagesc :
imagesc(255-uint8(spinImages(1,1).spinIm), [0 255])
imagesc(1-uint8(spinImages(1,1).spinIm), [0 255])
imagesc(uint8(spinImages(1,1).spinIm), [0 255])
but worthless. pleaz could you help me.

Best Answer

" but it doesn't work". In what way?
What you've showed will display the image, possibly not the way you want, but it will display it.
I'll note that the intensity range in your screenshot is up to 3906. Because of the call to uint8, any intensity above 255 will be set to 255. I'm not sure that's what you want.
There's certainly no reason to convert to uint8 if you're going to restrict the display range to [0 255] anyway.
Possibly, you meant:
imshow(spinImages(1,1).spinIm, [])