画素ごとの透明度を設定する方法がありますか?

19 views (last 30 days)
MathWorks Support Team
MathWorks Support Team on 27 Sep 2016
サイズが同じで、グレースケールの画像Aを表示した上、カラーの画像Bを画素ごとの透明度を設定して、重ね表示する方法を教えてください。

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Sep 2016
画像を表示する際に、「AlphaData」という透明度を設定するパラメータがありますので、このパラメータを利用すれば、画素ごとの透明度を設定した上の重ね表示が可能です。下記のサンプルコードをご参考ください。
- サンプルコード:
I=imread('cameraman.tif');
% グレースケール画像の表示
figure,image(I),truesize,colormap(gray(256))
J=imread('football.jpg');
J=J(:,1:256,:);
% カラー画像の表示
figure,image(J),truesize
figure,image(I),truesize,colormap(gray(256))
hold on
% AlphaDataパラメータの設定によって透明度の設定が可能です。
image(J,'AlphaData',0.5),truesize
hold off
figure,image(I),truesize,colormap(gray(256))
hold on
% AlphaDataパラメータに画像サイズと同じ大きさ(256×256)の行列(uint8データタイプ)を代入すれば、
% 行列の値により、ピクセル単位での透明度設定が可能です。
image(J,'AlphaData',I),truesize
hold off

More Answers (0)

Products


Release

R2010b

Community Treasure Hunt

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

Start Hunting!