グレースケール化のエラー

5 visualizaciones (últimos 30 días)
Kodai Sato
Kodai Sato el 6 de Oct. de 2020
Comentada: Kodai Sato el 6 de Oct. de 2020
以下のコードでグレースケール化を行おうと考えています.
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);
これは,どのような意味なのでしょうか?

Respuesta aceptada

Akira Agata
Akira Agata el 6 de Oct. de 2020
Editada: Akira Agata el 6 de Oct. de 2020
おそらく、もとの画像ファイルがインデックス付き画像ファイルになっていることが原因と思われます。
その場合、以下のようにいったん通常のRGB画像に変換したうえでグレースケール化すれば大丈夫です。
[IDX, cmap] = imread('2007_000033.png'); % インデックスとカラーマップを読み込み
RGB = ind2rgb(IDX, cmap); % 両者から通常のRGB画像に変換
I = rgb2gray(RGB); % グレースケール画像に変換
  1 comentario
Kodai Sato
Kodai Sato el 6 de Oct. de 2020
非常にわかりやすいご回答ありがとうございました.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Modify Image Colors en Help Center y File Exchange.

Productos


Versión

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!