画像の上に画像を貼り付ける

19 Ansichten (letzte 30 Tage)
akasa
akasa am 22 Jun. 2021
Kommentiert: akasa am 22 Jun. 2021
あるフルスクリーンの画像の上にもう一つの画像を貼り付けたいと考えているのです
が、そのような関数はありますでしょうか?
また、貼り付ける画像のサイズや場所を変更できると嬉しいです。

Akzeptierte Antwort

Hernia Baby
Hernia Baby am 22 Jun. 2021
Bearbeitet: Hernia Baby am 22 Jun. 2021
基本的に各座標に255までの数字をいれているだけなので、座標と範囲が分かれば貼り付け可能です。
貼り付けというより、上書きに近いです。
--------------
■こちら参考にしてみてください。
■画像の大きさを変更する場合は imresize を参照ください。
---------------
…少々、不親切なので例を入れておきます。
画像は愛犬と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 Kommentare
Hernia Baby
Hernia Baby am 22 Jun. 2021
Atsushi Uenoさん、代わりにありがとうございます。
おっしゃる通り、基本的なimread, imshow, imwrite関数はデフォルトで使えます。
Step3の上書きはmatlabでの通常の動作になります。
A = zeros(9);
A(3:5,4:6) = 1
A = 9×9
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0~255云々が画像になるについて
まずは適当な数字を書きます
x = linspace(255,0,12);
x = uint8(x);
I =reshape(x,[3,4])
I = 3×4
255 185 116 46 232 162 93 23 209 139 70 0
それを図示します。
imshow(I)
小さいので拡大すると以下のようになります。
imshow(I,'InitialMagnification','fit')
0は黒、255が白というのがわかります。
これがRed, Green, Blueの3セット分入るとRGBカラーで表示されます。
akasa
akasa am 22 Jun. 2021
お二方ご回答ありがとうございます。。
まだmatlabを使い始めて日が浅いので分からないことだらけなのですが、丁寧にご指摘いただき感謝します。

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Display Image finden Sie in Help Center und File Exchange

Tags

Produkte


Version

R2021a

Community Treasure Hunt

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

Start Hunting!