How to extract raw data from a rgb image visualized with known colormap?
47 ビュー (過去 30 日間)
表示 古いコメント
Hello, everyone,
I have a rgb image, and it was visualized with a known colormap. Now I want to extract the raw 2D matrix data rather than RGB values of this image before it was mapped to the colormap . How should I do?
Here is an example:
raw_data = rand(256,256);
figure;
imagesc(raw_data);
axis image off;
colormap(jet);
colorbar;
title('saved image');
Then I save this visualized image, names as, for example 'saved image.jpg'.
How should I retrieve 'raw_data' from 'saved_img.jpg' according to the known 'jet' colormap?
Thank you!
0 件のコメント
回答 (1 件)
Sameer Pujari
2022 年 10 月 27 日
Hello Xin Liu
From the given info, I understand that you want to get RGB image back after you have visualised with a known colormap.
To do that you have to first get the colormap of orignal rgb image
RGB = imread('image.jpg');
[X,cmap] = rgb2ind(RGB,65536);
Then you can get the original image back using
X = ind2rgb(X,cmap);
The same can be done by using "colormap" function for the figure
RGB = imread('image.jpg');
[X,map] = rgb2ind(RGB,65536);
figure
image(X)
axis off
axis image
colormap(parula) %image will be visualized in parula colormap
colormap(cmap) %image will be visualized in orignal rgb colormap
I hope this information helps you!
3 件のコメント
参考
カテゴリ
Find more on Blue in Help Center and File Exchange
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!