Azzera filtri
Azzera filtri

Adjust the color bar of all thermal images to be consistent

17 visualizzazioni (ultimi 30 giorni)
I want to adjust the color bar of some series of thermal images to be consistent for the convenience of studying the temperature change trend. May I ask what I should do? thank you

Risposta accettata

DGM il 2 Nov 2022
Modificato: DGM il 2 Nov 2022
Unless you have the underlying thermal data, you're going to have to convert the false-color image back into a grayscale thermal image. In order to do that, you need to extract the colorbar from the image and convert it to a colormap. You'll have to then extract the colorbar limit numbers from the image so that you can know how to scale the data.
At that point, you can take this RGB false color image and convert it to an indexed image and then rescale it into nominal temperature units. It may make sense to crop off the colorbar and other decorations from the image, since they'll be mapped to nonsense temperature values if you don't get rid of them.
You could then either display them on a common scale using the extracted colormap, or you could convert them back to RGB using ind2rgb() and some appropriate scaling.
This would be a good place to start.
Try this for a start:
% start with an image
A = imread('thermal1.bmp');
% extract the colormap from one image
% if the colormap is the same for all images, this can be reused
CT = A(50:270,219:229,:); % extract the colorbar region
CT = permute(mean(CT,2),[1 3 2]); % sample average
CT = unique(CT,'rows','stable'); % discard duplicate rows
CT = CT/255; % assuming input was uint8
CT = flipud(CT);
% somehow extract the numbers from the image
% i don't have any OCR stuff, so i'm just going to do this manually
cblimits = [26.1 32.3];
% crop out the usable part of the image
A = A(32:end,1:200,:);
% now you have one image rescaled into temperature units
Ath = double(rgb2ind(A,CT))/size(CT,1);
Ath = rescale(Ath,cblimits(1),cblimits(2));
% do the same things again for another image
B = imread('thermal2.bmp');
B = B(32:end,1:200,:);
cblimits = [22.3 26.9];
Bth = double(rgb2ind(B,CT))/size(CT,1);
Bth = rescale(Bth,cblimits(1),cblimits(2));
% display both images with a common scale and colormap
displaycbrange = [22 34]; % the common scale
  2 Commenti
wenze il 3 Nov 2022
Modificato: Image Analyst il 3 Nov 2022
Thanks for your answer,but I use your codes get this image,it·s the problem of colormap?
DGM il 3 Nov 2022
Modificato: DGM il 3 Nov 2022
What does CT look like?
What does colormap(gca) look like? Are they the same?
If it's an issue of the map not being assigned, you could always be more explicit:
ax1 = subplot(1,2,1);
ax2 = subplot(1,2,2);
... though I don't think it should be necessary.
If you're running an older version, or if you've adapted the code, it would help to know.

Accedi per commentare.

Più risposte (1)

Hiro Yoshino
Hiro Yoshino il 2 Nov 2022
You can control the range of colorbar with clim:
[X,Y] = meshgrid(-5:.5:5);
Z = X.^2 + Y.^2;
% Left plot
ax1 = nexttile;
% Right plot
ax2 = nexttile;
clim(ax2,[20 50]) % fix the color range of ax2
  3 Commenti
Hiro Yoshino
Hiro Yoshino il 2 Nov 2022
clim was introduced in R2020a, which was renamed from caxis.
Please try caxis with reference to the function in the old documentations (here).
DGM il 2 Nov 2022
The images are RGB images from a camera. Setting caxis has no effect on the rendering of a truecolor image.

Accedi per commentare.

Community Treasure Hunt

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

Start Hunting!

Translated by