How can I display a colored .png image with a specific color background ?

18 ビュー (過去 30 日間)
Abhay Singh
Abhay Singh 2020 年 9 月 4 日
編集済み: Abhay Singh 2020 年 9 月 7 日
I have been trying to display a png image with a certain background color (image background not the figure window background color), lets say [0.9 0.5 0.4]. I have gone through some of the forums but I don't get an expected result.
I have used imshow and image, while image shows a colorful picture. The following is my code:
[x,~,m] = imread('XYZ.png');
imshow(x);
set(gca,'Color',[0.9 0.5 0.4])
axis off;
I automatically get a yellow background, while the real image has white background.
In general, I would like to know how to change this yellow backgroundcolor to a given color code.

採用された回答

Amrtanshu Raj
Amrtanshu Raj 2020 年 9 月 7 日
Hi,
You can use the following code to set a background of your choice. Also ensure that the image has a transparent background else the effect will not be evident.
Hope this helps !
[x,~,m] = imread('discAluminumMask.png' ,'BackgroundColor',[.9 .9 0]) ;
  1 件のコメント
Abhay Singh
Abhay Singh 2020 年 9 月 7 日
編集済み: Abhay Singh 2020 年 9 月 7 日
I believe, what you say is correct and also it makes sense. Probably the figure I'm working with is not fully transparent. Thanks for the answer.
I'm using a ppt slide saved as .png. I believe its not transparent.

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by