MATLAB Answers

How to eliminate colormap?

5 views (last 30 days)
John Doe
John Doe on 3 Jun 2020
Edited: John Doe on 3 Jun 2020
a = imread('cameraman.tif') ;
image(a)
The commands are producing the image in a colormap, not in gray tone (original color). I do not want the colormap?
How to fix this without using imshow?
Thanks in advance!

  0 Comments

Sign in to comment.

Accepted Answer

Tommy
Tommy on 3 Jun 2020
When you supply a 2D array to image(), the values within that array are mapped to a colormap. The colormap is needed to convert scalar values to RGB triplets. imread() returns a 2D array for grayscale images, but you can supply the corresponding 3D array (where R=G=B) to image() if you want:
image(repmat(a,1,1,3))

  0 Comments

Sign in to comment.

More Answers (0)


Translated by