필터 지우기
필터 지우기

imshowで表示さ​れた画像の色を変更す​ることはできますか?

조회 수: 25 (최근 30일)
non
non 2023년 10월 12일
댓글: Hiroshi Iwamura 2023년 10월 14일
画像(214×407×3 double)をimshowで表示して、そのカラーバーを変更することはできますか?
添付しましたtest.matの背景を白にしたく、カラーバーの色の割り当てを変更できないかと考えております。
何かご存じのことありましたら、ご教示いただきたいです。
ご確認をよろしくお願いいたします。
  댓글 수: 2
Dyuman Joshi
Dyuman Joshi 2023년 10월 12일
Colorbar for a RGB image?
Do you just want to change the color of the background to white?
non
non 2023년 10월 12일
Dear Dyuman Joshi
I want to change the color of the background to white and type and value range of the color bar
I am having trouble changing the type and range of the color bar...
Is there such a thing as a color bar for a RGB image? test.mat was created by superimposing three monochannel images. I am wondering if this can be considered as RGB and displayed. Do I need to do some other analysis, such as changing the number of bits?
Sorry to ask so many questions. Thanks and Kind Regards.

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

채택된 답변

Hiroshi Iwamura
Hiroshi Iwamura 2023년 10월 12일
figure の背景色であれば
f = gcf; % または f = figure;
f.Color = [1 1 1];
test.mat の背景であれば、
NaNになっているようですのでとりあえず、
test2 = test;
test2(isnan(test2)) = 1;
とかで変えられるかと思います。
  댓글 수: 2
non
non 2023년 10월 12일
Hiroshi Iwamura様
ご回答をありがとうございます。
教えていただいた方法を試して、test.mat の背景を白に変更することができました。大変、ありがとうございます。
もう一点、教えていただくことは可能でしょうか。カラーバーの種類と値の範囲を変更したいです。Figureプロパティで試したものの、変更できませんでした。RGB画像では、カラーバーは使われないのでしょうか。test.matは3つのモノチャンネル画像を重ね合わせて作成しました。これをRGBとみなして表示するには、ビット数を変えるなど他の解析が必要でしょうか?
初学者で、初歩的なご質問ばかり申し訳ありません。何かご存じのことありましたら、ご教示をよろしくお願いいたします。
Hiroshi Iwamura
Hiroshi Iwamura 2023년 10월 14일
colormap、colorbar はインデックスカラーに使われます。
公式ドキュメントをご覧ください。
RGB画像そのままですとインデックスが1600万以上必要になりますので、
rgb2ind() でインデックスカラー化(色数削減)するのが良いと思います。
load('test.mat');
[IND,map] = rgb2ind(test,256); % 256色に削減
figure
imshow(IND,map)
colorbar
figure
imshow(IND,map)
colorbar
colormap(parula(256))
figure
imshow(IND,map)
colorbar
colormap(parula(32))
カラーマップは自由に設定できます。
cmap = colormap;
で現在の(システム)カラーマップが取れますので、参考にしてください。
imshow(IND,map) だけではシステムカラーマップには反映されないことに注意してください。
figure
imshow(IND,map)
colorbar
cmap2 = map;
cmap2(IND(1)+1,:) = [1 0.5 0]; % 左上の座標が背景とする 0-Base なので +1
colormap(cmap2) % カラーマップに反映
また、背景色のみをいじりたい場合は、透過PNGにするのが良いかもしれません。
alpha = double(~isnan(test(:,:,1)));
imwrite(test, "test.png",'Alpha',alpha)
[A,~,transparency] = imread('test.png','BackgroundColor',[1 0.5 0]);
imshow(A)
その他の画像処理に関しては公式ドキュメントをご覧ください。

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

추가 답변 (0개)

카테고리

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

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!