Adjust the color bar of all thermal images to be consistent
조회 수: 11 (최근 30일)
이전 댓글 표시
채택된 답변
DGM
2022년 11월 2일
편집: DGM
2022년 11월 2일
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.
EDIT:
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));
imshow(Ath,[])
% 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
subplot(1,2,1)
imshow(Ath,displaycbrange)
colormap(CT)
colorbar
subplot(1,2,2)
imshow(Bth,displaycbrange)
colormap(CT)
colorbar
댓글 수: 2
DGM
2022년 11월 3일
편집: DGM
2022년 11월 3일
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);
imshow(Ath,displaycbrange,'parent',ax1)
colormap(ax1,CT)
colorbar(ax1)
ax2 = subplot(1,2,2);
imshow(Bth,displaycbrange,'parent',ax2)
colormap(ax2,CT)
colorbar(ax2)
... 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.
추가 답변 (1개)
Hiro Yoshino
2022년 11월 2일
[X,Y] = meshgrid(-5:.5:5);
Z = X.^2 + Y.^2;
tiledlayout(1,2)
% Left plot
ax1 = nexttile;
surf(ax1,Z);
colorbar
% Right plot
ax2 = nexttile;
surf(ax2,Z);
colorbar
clim(ax2,[20 50]) % fix the color range of ax2
댓글 수: 3
Hiro Yoshino
2022년 11월 2일
clim was introduced in R2020a, which was renamed from caxis.
DGM
2022년 11월 2일
The images are RGB images from a camera. Setting caxis has no effect on the rendering of a truecolor image.
참고 항목
카테고리
Help Center 및 File Exchange에서 Red에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!