グレースケール化のエラー
8 views (last 30 days)
Show older comments
以下のコードでグレースケール化を行おうと考えています.
clear all;
close all;
%RGBイメージを表示
RGB = imread('2007_000033.png');
%imshow(RGB)
%RGB イメージをグレースケール イメージに変換して表示
I = rgb2gray(RGB);
figure
imshow(I)
しかしながら,実行したところ,以下のようなエラーが発生しました.
エラー: rgb2gray>parse_inputs (line 80)
MAP は m 行 3 列の配列でなければなりません。
エラー: rgb2gray (line 52)
isRGB = parse_inputs(X);
これは,どのような意味なのでしょうか?
0 Comments
Accepted Answer
Akira Agata
on 6 Oct 2020
Edited: Akira Agata
on 6 Oct 2020
おそらく、もとの画像ファイルがインデックス付き画像ファイルになっていることが原因と思われます。
その場合、以下のようにいったん通常のRGB画像に変換したうえでグレースケール化すれば大丈夫です。
[IDX, cmap] = imread('2007_000033.png'); % インデックスとカラーマップを読み込み
RGB = ind2rgb(IDX, cmap); % 両者から通常のRGB画像に変換
I = rgb2gray(RGB); % グレースケール画像に変換
More Answers (0)
See Also
Categories
Find more on Modify Image Colors 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!