Changing Transparent Background to White in Matlab
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')
精彩评论