png形式の画像をimreadで読み込もうとするが、R成分しか読み込めない。
Show older comments
png形式の画像ファイルをimreadを使用して読み込もうとしているのですが、R成分しか読み込めません。
具体的には、以下の様なコードを実行すると、「インデックスが行列の次元を超えています」と表示されます。
imageRGB = imread('ABC.png')
imageR= imageRGB(:,:,1);
imageG= imageRGB(:,:,2); -----------------------------ここ
imageB= imageRGB(:,:,3);
実際にwhos imageRGBを行っても、Sizeが6814×4768だけとなっており、R成分しか読み込めてないことが確認されました。
これを、windowsのペイントでbmp24ビット形式に変換すると、問題なくG,B成分も読み込めます。画像が大量にあるため、全て変換するのは困難なので、png形式のまま3平面とも読み込む方法はありますでしょうか。
ちなみに、imfinfoを行うと以下の様に表示されます。
Filename: '/home/rnakamura19/matlab_src/samples/Sample/20190123/Gra_x0.bmp_1.png'
FileModDate: '24-Jun-2020 18:54:37'
FileSize: 36363
Format: 'png'
FormatVersion: []
Width: 4768
Height: 6814
BitDepth: 8
ColorType: 'indexed'
FormatSignature: [137 80 78 71 13 10 26 10]
Colormap: [35x3 double]
Histogram: []
InterlaceType: 'none'
Transparency: 'none'
SimpleTransparencyData: []
BackgroundColor: 1
RenderingIntent: []
Chromaticities: [0.3127 0.3290 0.6400 0.3300 0.3000 0.6000 0.1500 0.0600]
Gamma: 0.4545
XResolution: []
YResolution: []
ResolutionUnit: []
XOffset: []
YOffset: []
OffsetUnit: []
SignificantBits: []
ImageModTime: '23 Jan 2019 20:42:04 +0000'
Title: []
Author: []
Description: []
Copyright: []
CreationTime: []
Software: []
Disclaimer: []
Warning: []
Source: []
Comment: []
OtherText: {2x2 cell}
Accepted Answer
More Answers (0)
Categories
Find more on イメージ in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!