フィルターのクリア

How to change the color of a 16bit image from Grays to a color mode?

4 ビュー (過去 30 日間)
Shirley
Shirley 2019 年 9 月 12 日
コメント済み: Shirley 2019 年 9 月 17 日
Hi
I have an image which is 16bit. It is grays. I wonder how can I change it to a specific color, e.g, Yellow? I tried to convert it to RGB first, but somehow [I,map]=imread(16bitimage) doesn't give the colormap.
Thanks a lot

採用された回答

Shirley
Shirley 2019 年 9 月 12 日
編集済み: Walter Roberson 2019 年 9 月 12 日
I found that this works for me. Suggestions are more than welcome. Thanks
1)self define a colormap, e.g
%Yellow [1 1 0]
YellowColormap=zeros(256,3);
for i=1:256
YellowColormap(i,1) = (i-1)/256;
YellowColormap(i,2) = (i-1)/256;
end
2)X=imread(16bit image);
imshow(X,'DisplayRange',[0 65535],'Colormap',YellowColorMap)
  2 件のコメント
Image Analyst
Image Analyst 2019 年 9 月 13 日
Or, vectorized:
YellowColormap = gray(256);
YellowColormap(:,3) = 0;
Shirley
Shirley 2019 年 9 月 13 日
That is clever! I didn't know this function before. Thanks a lot!

サインインしてコメントする。

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2019 年 9 月 12 日
image_as_rgb = repmat(image_as_gray, [1 1 3]);
Now you can manipulate image_as_rgb .
Or you might prefer to use ind2rgb() -- though to do that you need to define a colormap that has as many entries as max(image_as_gray)+1, which for a 16 bit image could be as many as 65536 entries.
  5 件のコメント
Walter Roberson
Walter Roberson 2019 年 9 月 15 日
yellow_image = cat(3, repmat(mat2gray(image_as_gray), [1 1 2]), zeros(size(image_as_gray)));
imshow(yellow_image)
You have a uint16 image, but your data range is only a small fraction of uint16.
Shirley
Shirley 2019 年 9 月 17 日
Thanks! It works now after I adjusted the image

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeOrange についてさらに検索

タグ

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by