Converting a color image into a set of data

21 vues (au cours des 30 derniers jours)
Adam Johnston
Adam Johnston le 26 Juin 2024
Modifié(e) : Adam Johnston le 27 Juin 2024
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.

Réponse acceptée

DGM
DGM le 27 Juin 2024
Modifié(e) : DGM le 27 Juin 2024
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 commentaire
Adam Johnston
Adam Johnston le 27 Juin 2024
Modifié(e) : Adam Johnston le 27 Juin 2024
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.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Red dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by