How can I link the color of an image to a defined temperature?
1 view (last 30 days)
Show older comments
I'm working on this image as following:
RGB = imread('Flame1.jpg');
[X,map] = rgb2ind(RGB,3);
imagesc(X)
cmap = colormap(map);
colormap('hsv')
axis off
axis image
c = colorbar;
c.Limits = [-4 4];
c.Ticks = [-4 1 4];
c.TickLabels = {'800\circ C','900\circ C','1000\circ C'};
In this way on the colorbar to each temperature (800 °C, 900 °C and 1000 °C) it will correspond red, green and blue respectively as it's showed in the colormap. However, what I did is a manual assignement since I customize the colorbar manually. I was wondering if there is a way to link the colors of the colorbar and the colormap to the temperature.
If not, is there a better way to link the colors to the assigned temperature?
6 Comments
Adam Danz
on 13 May 2021
I came across this file exchange submission today that may be helpful to you
Answers (1)
Sanju
on 29 Feb 2024
I understand that you want to link the colour of an image automatically to a defined temperature,
Currently there is no built-in functionality in MATLAB that directly links the colors of the colorbar and the colormap to the temperature values. The manual assignment you have done is a common approach in such cases.
However, if you have a specific temperature-to-color mapping that you would like to achieve, you can create a custom colormap using the colormap function. By defining a colormap that smoothly transitions between colors, you can visually represent the temperature values with corresponding colors.
To create a custom colormap you may refer to the following code:
% Define the temperature values and their corresponding colors
temperature = [-4, 1, 4];
colors = [1 0 0; 0 1 0; 0 0 1]; % Red, Green, Blue
% Create a custom colormap
custom_cmap = interp1(temperature, colors, linspace(-4, 4, 256));
% Apply the custom colormap
colormap(custom_cmap);
%Add your code here
....
You can also refer to the following link for more information,
Hope this helps!
0 Comments
See Also
Categories
Find more on Red in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!