フィルターのクリア

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

2 ビュー (過去 30 日間)
Enne
Enne 2021 年 4 月 28 日
回答済み: Sanju 2024 年 2 月 29 日
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 件のコメント
Adam Danz
Adam Danz 2021 年 5 月 13 日
I came across this file exchange submission today that may be helpful to you
Enne
Enne 2021 年 5 月 19 日
Thank you @Adam Danz, I tried to run this code with the examples given by the user itself but apparently it doesn't work

サインインしてコメントする。

回答 (1 件)

Sanju
Sanju 2024 年 2 月 29 日
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!

カテゴリ

Help Center および File ExchangeBlue についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by