【问题标题】:Changing Transparent Background to White in Matlab在 Matlab 中将透明背景更改为白色
【发布时间】:2011-10-02 06:36:03
【问题描述】:

请考虑以下一段 Matlab 代码:

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

我面临的问题是 a.png 具有透明背景。当我将其保存为 jpg 时,它会将图像保存为黑色背景。

请告诉我如何使背景变白。我需要以编程方式执行此操作,因为我有 1000 多个文件要处理。

我希望你能给我写代码,因为我对 Matlab 不是很精通。

问候

【问题讨论】:

    标签: matlab image-processing png density-independent-pixel


    【解决方案1】:

    尝试以下方法:

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

    【讨论】:

    • @Haider: 你能发一张PNG图片样本(透明背景),这样我们就可以试验了……
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-06-22
    • 1970-01-01
    • 2016-08-15
    • 1970-01-01
    • 2014-08-21
    • 2011-02-12
    • 1970-01-01
    相关资源
    最近更新 更多