What does 'Colormap' do to the image with double/float pixels?

6 Ansichten (letzte 30 Tage)
gccat
gccat am 5 Apr. 2019
Beantwortet: Steven Lord am 8 Apr. 2019
I think that 'Colormap' is for index image which has only integer elements
however, when I use the code below
%Img is gray scale
Img=Img-min(Img(:));
Img=Img./(max(Img(:))-min(Img(:)));
imshow(Img,[],'Colormap',jet(256))
Colormap can also work and produce a color image (if it is without 'Colormap', the result become black and white)
What does 'Colormap' do to the image with double/float pixels?
  3 Kommentare
gccat
gccat am 6 Apr. 2019
Thank you, this is really helpful !
Image Analyst
Image Analyst am 6 Apr. 2019
Adam, can you post this as an official "Answer" down below in the official Answers section, rather than up here in Comments which is supposed to be used for asking the poster to clarify their question? You can even get "Credit" for it down there, unlike up here.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Adam
Adam am 8 Apr. 2019
Data is linearly binned into however many bins/elements your colourmap has and that colour applied.
e.g. if your data is 0-1 and you had a 10-element colourmap then it would be split
0-0.1 - 1st colour
0.1-0.2 - 2nd colour
etc
Obviously 0.1 would map to only 1 colour with either a < or <= relationship used, but this is just a rough example of what happens anyway.
Which is the same, by the way, as for integer images anyway as unless your integer images has the same number of values (and indexed from 1) as your colourmap the data still has to be binned.

Weitere Antworten (1)

Steven Lord
Steven Lord am 8 Apr. 2019
Since your variable name is img, I assume you're planning to display this using the image function in MATLAB. If so look at the CDataMapping name-value pair argument and the C input argument in the Input Arguments section on that documentation page.

Kategorien

Mehr zu Colormaps finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by