画像データの軸プロパティについて質問です。

6 visualizzazioni (ultimi 30 giorni)
KO
KO il 13 Giu 2021
Commentato: KO il 13 Giu 2021
imreadで読み込んだ画像データは,添付のように,元画像データのままx=560,y=380の座標軸で表示されますが,これをx=1000,y=1000の座標平面の中心に置くことはできますか?
画像データはx=560,y=380のサイズのままで,外枠を余白にしたいです.つまり,1000×1000の座標平面で,画像データをx方向に220,y方向に310平行移動したいです.
ご存知の方,よろしくお願いいたします。

Risposta accettata

Atsushi Ueno
Atsushi Ueno il 13 Giu 2021
下記の様に画像データは行列データと同様に操作出来ます。型がuint8(0:黒~255:白)で、RGB3色分ある点に注意です。
img = imread('img.jpg');
image(img)
[h w ~] = size(img); % h=380, w=560
w2 = 1000;
h2 = 1000;
x = (w2-w)/2; % x=220 平行移動量
y = (h2-h)/2; % y=310 垂直移動量
bgd = uint8(ones(w2,h2,3)*255); % bgdは1000×1000の座標平面
bgd(y:y+h-1,x:x+w-1,:) = img; % 座標平面の中心にimg.jpgを置く
image(bgd)
  1 Commento
KO
KO il 13 Giu 2021
すごくわかりやすいです.画像も行列データということが分かれば理解しやすいですね.
いつも本当にありがとうございます。

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!