【问题标题】:Matlab imwrite changed my colourMatlab imwrite 改变了我的颜色
【发布时间】:2018-11-16 02:17:28
【问题描述】:

我正在尝试将一些类似的图像从 gif 转换为 png。 你可以在这里找到两张图片: https://europa.eu/european-union/about-eu/history/1980-1989_en。 转换第一个 gif(1981 年)后,您可以看到背景颜色和以前一样,白色,但是对于第二个 gif(1986 年),背景颜色变为粉红色。如何解决?

下面是我的代码:

file_in = uigetfile('*.*', 'All Files', 'MultiSelect','on');
file_out = cellfun(@(x) cat(2, x(1:(length(x)-3)), 'png'),...
   file_in, 'UniformOutput', false); 

for i = 1: length(file_in)    
   [gif,map] = imread (file_in{i});
   imwrite (gif, map, file_out{i}, 'Background', [0 0 0]);
end

【问题讨论】:

    标签: image matlab image-processing gif colormap


    【解决方案1】:

    Matlab 在转换后从未改变图像颜色。因此,如果您尝试通过imshow 打开“gif”或“png”,您将得到相同的结果。

    无论如何,如果您想将背景颜色更改为白色,请使用this code

    【讨论】:

    • 谢谢!但我很困惑。为什么用火狐浏览器或者Windows相册查看图片背景是白色的?
    • 它基于软件如何解释颜色值。
    猜你喜欢
    • 2017-07-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-11-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多