画像の上に画像を貼り付ける
20 views (last 30 days)
Show older comments
あるフルスクリーンの画像の上にもう一つの画像を貼り付けたいと考えているのです
が、そのような関数はありますでしょうか?
また、貼り付ける画像のサイズや場所を変更できると嬉しいです。
0 Comments
Accepted Answer
Hernia Baby
on 22 Jun 2021
Edited: Hernia Baby
on 22 Jun 2021
基本的に各座標に255までの数字をいれているだけなので、座標と範囲が分かれば貼り付け可能です。
貼り付けというより、上書きに近いです。
--------------
■こちら参考にしてみてください。
---------------
…少々、不親切なので例を入れておきます。
画像は愛犬とmatlabのアイコンです。
Step1. 写真を読み込みます
clc,clear,close all;
dog = imread('chacha.jpeg');
icon = imread('matlab_icon.png');
[xe_d,ye_d,~] = size(dog);
[xe_i,ye_i,~] = size(icon);
dog1 = dog;
montage({dog,icon});
Step2. 範囲を決めます(今回は右下に貼り付けます)
xs = xe_d - xe_i;
ys = ye_d - ye_i;
xe = xs + xe_i;
ye = ys + ye_i;
Step3. 上書きします
dog1(xs+1:xe,ys+1:ye,:) = icon;
imshow(dog1);
4 Comments
Hernia Baby
on 22 Jun 2021
Atsushi Uenoさん、代わりにありがとうございます。
おっしゃる通り、基本的なimread, imshow, imwrite関数はデフォルトで使えます。
Step3の上書きはmatlabでの通常の動作になります。
A = zeros(9);
A(3:5,4:6) = 1
0~255云々が画像になるについて
まずは適当な数字を書きます
x = linspace(255,0,12);
x = uint8(x);
I =reshape(x,[3,4])
それを図示します。
imshow(I)
小さいので拡大すると以下のようになります。
imshow(I,'InitialMagnification','fit')
0は黒、255が白というのがわかります。
これがRed, Green, Blueの3セット分入るとRGBカラーで表示されます。
More Answers (0)
See Also
Categories
Find more on Display Image 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!