現在Matlabを勉強中の者です.
160*120ピクセルの画像の色空間を
RGBからYUV(YCbCr)へ変換するプログラムを考えているのですが,
以下のソースコードで大まかな点はあっているでしょうか?
実際にYUVへ変換後,画像を表示したところ,
元画像とは色調が変わってしまい頭を抱えています.
画像を表示する際のカラーマップに問題があるのでしょうか.
ご教授お願い致します.
% 画像ファイルの読込
pictureRgb = imread('./data/gazou0.bmp');
pictureYcbcr = imread('./data/gazou0.bmp');
% YCbCr空間(フルレンジ)への変換
pictureYcbcr(:,:,1) = uint8(0.257 * double(pictureRgb(:,:,1)) + 0.504 * double(pictureRgb(:,:,2))...
+ 0.098 * double(pictureRgb(:,:,3))+16.0);
pictureYcbcr(:,:,2) = uint8(-0.148 * double(pictureRgb(:,:,1)) - 0.291 * double(pictureRgb(:,:,2))...
+ 0.439 * double(pictureRgb(:,:,3))+128.0);
pictureYcbcr(:,:,3) = uint8(0.439 * double(pictureRgb(:,:,1)) - 0.368 * double(pictureRgb(:,:,2))...
+ 0.071 * double(pictureRgb(:,:,3))+128.0);
%R成分の表示
subplot(3,3,1);
image(pictureRgb(:,:,1));
axis image; axis off;
title('R 成分');
%G成分の表示
subplot(3,3,2);
image(pictureRgb(:,:,2));
axis image; axis off;
title('G 成分');
%B成分の表示
subplot(3,3,3);
image(pictureRgb(:,:,3));
axis image; axis off;
title('B 成分');
%---------------------------
%Y成分の表示
subplot(3,3,4);
image(pictureYcbcr(:,:,1));
axis image; axis off;
title('Y 成分');
%Cb成分の表示
subplot(3,3,5);
image(pictureYcbcr(:,:,2));
axis image; axis off;
title('Cb成分');
%Cr成分の表示
subplot(3,3,6);
image(pictureYcbcr(:,:,3));
axis image; axis off;
title('Cr成分');
%---------------------------
%原画像の表示
subplot(3,3,7);
image(pictureRgb);
axis image; axis off;
title('元画像');
%YUV画像の表示
subplot(3,3,8);
image(pictureYcbcr);
axis image; axis off;
title('YUV画像');
No.1ベストアンサー
- 回答日時:
Matlabはよく知らないのでそれについては分かりませんが
添付画像見る限り原画のRGB分離自体もまともに出来てないのでは?と思いますけど
(普通グレー(白黒濃淡)画像にならないとおかしいと思うんですがなぜ青とか茶色???)
回答ありがとうございます.
Matlabの仕様で,濃淡を「低い値程青く,高い値程赤に近い」
というモードで表示されていたので
colormap(gray);
というコマンドを追加すると白黒濃淡の画像で表示できました.
画像を張り直そうとしたのですが,画像の投稿は一度切りのようですね.
困りました…苦笑
お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!
関連するカテゴリからQ&Aを探す
おすすめ情報
- ・漫画をレンタルでお得に読める!
- ・人生のプチ美学を教えてください!!
- ・10秒目をつむったら…
- ・あなたの習慣について教えてください!!
- ・牛、豚、鶏、どれか一つ食べられなくなるとしたら?
- ・【大喜利】【投稿~9/18】 おとぎ話『桃太郎』の知られざるエピソード
- ・街中で見かけて「グッときた人」の思い出
- ・「一気に最後まで読んだ」本、教えて下さい!
- ・幼稚園時代「何組」でしたか?
- ・激凹みから立ち直る方法
- ・1つだけ過去を変えられるとしたら?
- ・【あるあるbot連動企画】あるあるbotに投稿したけど採用されなかったあるある募集
- ・【あるあるbot連動企画】フォロワー20万人のアカウントであなたのあるあるを披露してみませんか?
- ・映画のエンドロール観る派?観ない派?
- ・海外旅行から帰ってきたら、まず何を食べる?
- ・誕生日にもらった意外なもの
- ・天使と悪魔選手権
- ・ちょっと先の未来クイズ第2問
- ・【大喜利】【投稿~9/7】 ロボットの住む世界で流行ってる罰ゲームとは?
- ・推しミネラルウォーターはありますか?
- ・都道府県穴埋めゲーム
- ・この人頭いいなと思ったエピソード
- ・準・究極の選択
デイリーランキングこのカテゴリの人気デイリーQ&Aランキング
-
pictureboxに表示した画像のフ...
-
libpngでpng操作がうまくいかない
-
PHP MySQLに画像を直接保存
-
PHPでDBとディレクトリへの画像...
-
PHPで吐き出した画像にリンクを...
-
youtubeに音声のみのmp4ファイ...
-
CFileDialogの最初のディレクト...
-
フォントの色を変えるには?
-
onedrive にexcelファイルをア...
-
php エラー
-
PHPパーミッションについて
-
「クラス関数」「メンバ関数」...
-
.phpファイルが、表示されない
-
fputcsvで保存せず、そのまま出...
-
PHPから別なPHPへ移動(?)する方法
-
AccessのDoCmd.SendObjectについて
-
PHPで新しいウインドウで開く命...
-
phpでメール送信できません 原...
-
Ethnaの基本設定について
-
phpのクラスにて別ファイルの変...
マンスリーランキングこのカテゴリの人気マンスリーQ&Aランキング
-
VBSの「MsgBox」について
-
透過PNGが透過されない!!
-
拡張子php画像をjpg画像等に変...
-
C# Excelファイルへの画像挿入。
-
php,mysqlにて画像パス保存/表...
-
OpenGLで描いて画像ファイル出力
-
move_uploaded_fileのエラーについ
-
PythonのTkinter詳しい方へ。画...
-
SQLiteに画像を格納したい
-
ListViewコントロールでサムネ...
-
C#とJavaで、MP3タグの画像を表...
-
手作業で埋め込んだ、UserForm1...
-
画像リストを作りたい
-
【PHP】サーバー上で TIFFをJPE...
-
BLOBデーターの画像の表示方法...
-
DBに格納された画像データを縮...
-
VBAでJPGサイズ変更
-
どの画像がクリックされたかフ...
-
PHPで吐き出した画像にリンクを...
-
PHP MySQLに画像を直接保存
おすすめ情報