Is 2d colormap supported by matlab?

Generally in matlab we use 1D gradient colormap as
How do we use colormap like this

6 Comments

A 2D "colormap" is called an "image".
I meant to apply this colormap to image, not plot this colormap as image
Stephen23
Stephen23 on 28 Aug 2017
Edited: Stephen23 on 28 Aug 2017
A colormap is one dimensional, and scales to values. If you want to map by multiple dimensions, then use interpolation, indexing, mapping, or something similar.
Your indexed or grayscale image has a single value (per pixel). This value is then used as an index into a 1-D colormap to basically turn a gray scale value into a color. If your colormap has two dimensions, then exactly what would you use as indexes to pick the color from your 2-D colormap? Of course the gray level will be one index, but what would you use as the second index? All you have is the graylevel, which can be used to select the column to use from your 2-D colormap, unless you're supplying some other attribute to select the row of your 21-D colormap.
@ImageAnalyst Yes, you are right. The color and the brightness represent two data sets. I found an example here
Stephen23
Stephen23 on 28 Aug 2017
Edited: Stephen23 on 28 Aug 2017

Sign in to comment.

 Accepted Answer

Ray, if you have two parameters, air pressure and frequency, you can't use a colormap and you'll have to create an RGB image instead. You can get the color like this, assuming air pressure and frequency are the row and column of your "colormap" image:
for col = 1 : columns
for row = 1 : rows
thisColor = colormap2D(frequency(row, column), pressure(row, column), :) % A 1-by-3 vector
rgbImage(row, column, :) = thisColor;
end
end
So it has a pressure image and a frequency image. For exvery pixel, it gets the pressure and frequency and uses those as an index to get the desired color for that pixel, which it assigns to a new RGB image.

More Answers (0)

Categories

Community Treasure Hunt

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

Start Hunting!