Borrar filtros
Borrar filtros

How can I link the color of an image to a defined temperature?

2 visualizaciones (últimos 30 días)
Enne
Enne el 28 de Abr. de 2021
Respondida: Sanju el 29 de Feb. de 2024
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 comentarios
Adam Danz
Adam Danz el 13 de Mayo de 2021
I came across this file exchange submission today that may be helpful to you
Enne
Enne el 19 de Mayo de 2021
Thank you @Adam Danz, I tried to run this code with the examples given by the user itself but apparently it doesn't work

Iniciar sesión para comentar.

Respuestas (1)

Sanju
Sanju el 29 de Feb. de 2024
Hi Enne,
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!

Categorías

Más información sobre Blue en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by