开发者

Changing Transparent Background to White in Matlab

开发者 https://www.devze.com 2023-03-19 09:17 出处:网络
Plea开发者_C百科se consider the following piece of Matlab code: MyImage = imread(\'a.png\'); imwrite(MyImage, \'a.jpg\', \'jpg\');

Plea开发者_C百科se 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


Try the following:

I = imread('file.png', 'BackgroundColor',[1 1 1]);
imwrite(I, 'file.jpg')
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号