Azzera filtri
Azzera filtri

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

25 visualizzazioni (ultimi 30 giorni)
non
non il 12 Ott 2023
Commentato: Hiroshi Iwamura il 14 Ott 2023
画像(214×407×3 double)をimshowで表示して、そのカラーバーを変更することはできますか?
添付しましたtest.matの背景を白にしたく、カラーバーの色の割り当てを変更できないかと考えております。
何かご存じのことありましたら、ご教示いただきたいです。
ご確認をよろしくお願いいたします。
  2 Commenti
Dyuman Joshi
Dyuman Joshi il 12 Ott 2023
Colorbar for a RGB image?
Do you just want to change the color of the background to white?
non
non il 12 Ott 2023
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.

Accedi per commentare.

Risposta accettata

Hiroshi Iwamura
Hiroshi Iwamura il 12 Ott 2023
figure の背景色であれば
f = gcf; % または f = figure;
f.Color = [1 1 1];
test.mat の背景であれば、
NaNになっているようですのでとりあえず、
test2 = test;
test2(isnan(test2)) = 1;
とかで変えられるかと思います。
  2 Commenti
non
non il 12 Ott 2023
Hiroshi Iwamura様
ご回答をありがとうございます。
教えていただいた方法を試して、test.mat の背景を白に変更することができました。大変、ありがとうございます。
もう一点、教えていただくことは可能でしょうか。カラーバーの種類と値の範囲を変更したいです。Figureプロパティで試したものの、変更できませんでした。RGB画像では、カラーバーは使われないのでしょうか。test.matは3つのモノチャンネル画像を重ね合わせて作成しました。これをRGBとみなして表示するには、ビット数を変えるなど他の解析が必要でしょうか?
初学者で、初歩的なご質問ばかり申し訳ありません。何かご存じのことありましたら、ご教示をよろしくお願いいたします。
Hiroshi Iwamura
Hiroshi Iwamura il 14 Ott 2023
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)
その他の画像処理に関しては公式ドキュメントをご覧ください。

Accedi per commentare.

Più risposte (0)

Prodotti


Release

R2021b

Community Treasure Hunt

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

Start Hunting!