関数を使用せずに画像をグレースケールに変換したいです。
Afficher commentaires plus anciens
画像とサイズを読み込んでからfor文で各画素にグレースケール変換をしたいです
Réponse acceptée
Plus de réponses (2)
3番目がR,G,Bに対応しているので、for文で抜き出します
I = imread('ngc6543a.jpg');
for ii = 1:3
A{ii} = I(:,:,ii);
end
montage([A{1},A{2},A{3}])
1 commentaire
ちなみにRGBのみを分離する関数もあります
imsplit関数です
I = imread('ngc6543a.jpg');
[R,G,B] = imsplit(I);
ここから指定の色以外を黒で設定して表示してみましょう
allBlack = zeros(size(I,1,2),class(I));
justR = cat(3,R,allBlack,allBlack);
justG = cat(3,allBlack,G,allBlack);
justB = cat(3,allBlack,allBlack,B);
figure
montage({justR,justG,justB},'Size',[1 3], ...
"BackgroundColor",'w',"BorderSize",10);
title('Color Representation of the Red, Green, and Blue Color Channels');
> 関数を使用せずに画像をグレースケールに変換したいです
> 画像とサイズを読み込んでからfor文で各画素にグレースケール変換をしたいです
我慢出来ない!行列操作や型変換は関数であっても関数の内に入らない!
I = imread('onion.png');
[row,col,wdh] = size(I);
G1 = reshape(double(I(:)), [], wdh) * [0.2989; 0.5870; 0.1140];
G2 = uint8(reshape(G1, [row,col]));
imshow(G2);
Catégories
En savoir plus sur イメージ タイプの変換 dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


