필터 지우기
필터 지우기

Converting a color image into a set of data

조회 수: 27 (최근 30일)
Adam Johnston
Adam Johnston 2024년 6월 26일 15:30
편집: Adam Johnston 2024년 6월 27일 14:55
Hi, I have a thermal image in png form, with a color scale/map to go with it of a cell. I am just looking to try and converrt the colors to the designated values based on the color scale/map to the different values based on the color map. Then I am looking to create a graph of the color intesnsity verus distance along the cell. I have attached an image of what I am trying to convert, if you have any tips or information that may help that would be greately appreciated.

채택된 답변

DGM
DGM 2024년 6월 27일 1:01
편집: DGM 2024년 6월 27일 1:29
I've posted a number of demos on estimating data from a pseducolor image, including thermal images. You need a clean pseudocolor image, a good copy of the colormap it uses, and some idea how the mapping relates to the original data.
% read the image
inpict = imread('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1723241/image.png');
% crop out the colorbar and convert it to a color table
CT0 = imcrop(inpict,[622.51 67.51 21.98 545.98]);
CT0 = permute(mean(im2double(CT0),2),[1 3 2]);
CT0 = unique(CT0,'rows','stable');
CT0 = flipud(CT0);
% crop out the main image region
inpict = imcrop(inpict,[0.51 29.51 620.98 631.98]);
% estimate the original data from the pseudocolor visualization
zrange = [1 10];
Z = rgb2ind(inpict,CT0,'nodither');
Z = rescale(Z,zrange(1),zrange(2),'inputmin',0,'inputmax',size(CT0,1)-1);
% visualize the remapping
imagesc(Z)
colorbar
colormap(CT0)
As you can see, we can go through the motions, but the output is terrible. The colors in the ROI aren't present in the colorbar, so everything gets mapped inaccurately.
Either that's a composite thermal image, or the figure itself is a composite image and the colorbar doesn't belong. If it's a composite image, could it be decomposed? Maybe, but not based on a single image without having any other information about what it is or isn't.
I can only guess, but it really looks like it's the wrong colorbar, and thus, the wrong colormap.
Note that I have made no attempt to deal with how the padded areas outside the ROI are mapped.
EDIT:. Yes. That's a fake plot. That is not the colormap used in the ROI. It's just jet(). This is the color population in the ROI.
This is the color population in the colorbar.
This is jet().
So now that you know it's a fake plot, how do you estimate the data? You don't. You throw it away because it's a fake image. It's just a bunch of colors on the screen. There is no information to map it back to the original data. It's just a wild goose chase.
  댓글 수: 1
Adam Johnston
Adam Johnston 2024년 6월 27일 14:42
편집: Adam Johnston 2024년 6월 27일 14:55
Ay thank you for your help I appreciate it, you are indeed right, that image does not match with that color bar, I am just not allowed to share the acutal image, I just took a random image and was looking for the steps on how to do it. I will apply what you have done. Thanks.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Blue에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by