在 matlab 中读取时背景从白色转换为灰色
Background converted from white to grey when read in matlab
我有这张图片:
可以看出背景是白色的,在 finder/explorer 中查看时显示背景为白色或非常浅的灰色。
但是当我使用基本命令将此图像读入 matlab 时:imread(img_name);
读入是这样的:
为什么要改变背景颜色?
我认为它可能已编入索引并尝试使用以下命令将其转换回灰色:
[map, im] = imread(img_name);
new = in2gray(im, map);
但这并没有奏效,因为我收到一条错误消息,指出 map
不是有效的颜色映射
编辑
imfinfo
添加输出:
Filename: 'U:\IAM_manual0.png'
FileModDate: '27-Jun-2015 17:32:03'
FileSize: 1843331
Format: 'png'
FormatVersion: []
Width: 2078
Height: 2056
BitDepth: 8
ColorType: 'indexed'
FormatSignature: [137 80 78 71 13 10 26 10]
Colormap: [256x3 double]
Histogram: []
InterlaceType: 'none'
Transparency: 'none'
SimpleTransparencyData: []
BackgroundColor: []
RenderingIntent: 'perceptual'
Chromaticities: [0.3127 0.3290 0.6400 0.3300 0.3000 0.6000 0.1500 0.0600]
Gamma: 0.4545
XResolution: 3779
YResolution: 3779
ResolutionUnit: 'meter'
XOffset: []
YOffset: []
OffsetUnit: []
SignificantBits: []
ImageModTime: []
Title: []
Author: []
Description: []
Copyright: []
CreationTime: []
Software: 'paint.net 4.0.5'
Disclaimer: []
Warning: []
Source: []
Comment: []
OtherText: []
看来你的图片确实是索引图片,你应该阅读图片和颜色图:
[img map] = imread( img_name ); %// note that img is BEFORE map output
imshow( img, map );
应该可以解决问题。
我有这张图片:
但是当我使用基本命令将此图像读入 matlab 时:imread(img_name);
读入是这样的:
为什么要改变背景颜色?
我认为它可能已编入索引并尝试使用以下命令将其转换回灰色:
[map, im] = imread(img_name);
new = in2gray(im, map);
但这并没有奏效,因为我收到一条错误消息,指出 map
不是有效的颜色映射
编辑
imfinfo
添加输出:
Filename: 'U:\IAM_manual0.png'
FileModDate: '27-Jun-2015 17:32:03'
FileSize: 1843331
Format: 'png'
FormatVersion: []
Width: 2078
Height: 2056
BitDepth: 8
ColorType: 'indexed'
FormatSignature: [137 80 78 71 13 10 26 10]
Colormap: [256x3 double]
Histogram: []
InterlaceType: 'none'
Transparency: 'none'
SimpleTransparencyData: []
BackgroundColor: []
RenderingIntent: 'perceptual'
Chromaticities: [0.3127 0.3290 0.6400 0.3300 0.3000 0.6000 0.1500 0.0600]
Gamma: 0.4545
XResolution: 3779
YResolution: 3779
ResolutionUnit: 'meter'
XOffset: []
YOffset: []
OffsetUnit: []
SignificantBits: []
ImageModTime: []
Title: []
Author: []
Description: []
Copyright: []
CreationTime: []
Software: 'paint.net 4.0.5'
Disclaimer: []
Warning: []
Source: []
Comment: []
OtherText: []
看来你的图片确实是索引图片,你应该阅读图片和颜色图:
[img map] = imread( img_name ); %// note that img is BEFORE map output
imshow( img, map );
应该可以解决问题。