Question
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.
Expert Answer
Neeta Dsouza
PhD Expert
Answered Aug 15, 2026
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.
[x,~,m] = imread('discAluminumMask.webp' ,'BackgroundColor',[.9 .9 0]) ;
100% Run Guarantee
3-Hour Fast-Track Delivery
Need a Custom Version or Complete Simulation for This Problem?
Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.
Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee
Have a different question? Ask here
Related matlab Questions & Solutions
Browse All →
Explore similar technical troubleshooting questions and verified MATLAB solutions:
Ready-to-Run MATLAB & Simulink Projects
Browse All Projects →