1

Please consider the following piece of Matlab code:

  MyImage = imread('a.png');
  imwrite(MyImage, 'a.jpg', 'jpg');

The problem I am facing is that a.png has a transparent background. When I save it as jpg, it saves the image with black background.

Kindly please them me how to make the background white. I need to do this programmatically since I have 1000s of files to process.

I would prefer if you could write me the code, since I am not very proficient with Matlab.

Regards

Haider
  • 938
  • 2
  • 11
  • 25

1 Answers1

1

Try the following:

I = imread('file.png', 'BackgroundColor',[1 1 1]);
imwrite(I, 'file.jpg')
Amro
  • 123,847
  • 25
  • 243
  • 454
  • @Haider: could you post a sample PNG image (with transparent background) so we can experiment with... – Amro Jul 11 '11 at 10:53