グラフの背景に画像を表示させたい

お世話になります。
グラフ(axes)の背景にpng画像を、グラフの軸とは無関係に表示させたいです。
グラフに画像を表示する方法としては、imreadで読込んだイメージデータをimshowやimageを用いて表示する方法がありますが、これらはグラフの軸と画像のサイズ(縦横ピクセル数)が関係性を持ってしまい、例えば「X軸とY軸の最大値が100のグラフに、300x300ピクセルの画像を縮小せずに表示する」という事ができない認識です(X軸・Y軸が300まで拡張されてしまう)。
最終的にやりたいことは、背景画像が表示されているグラフ上をクリックし、クリックした点を直線で結ぶという処理です。
背景画像が無い状態で「クリックした点を直線で結ぶ」という実装はできておりますので、後はグラフに背景画像を表示させるだけです。
よろしくお願い致します。

 Respuesta aceptada

Shunichi Kusano
Shunichi Kusano el 3 de Dic. de 2019

3 votos

画像をリサイズしてから表示するというのはどうでしょうか。

2 comentarios

Akira Agata
Akira Agata el 3 de Dic. de 2019
Editada: Akira Agata el 3 de Dic. de 2019
あるいは axes を2つ重ねて、画像とプロットをそれぞれ表示させたうえで、プロット側の axes の背景を透明にする、というのはどうでしょうか。以下は簡単なサンプルです。
% Sample image
I = imread('peppers.png');
figure
ax1 = axes;
ax2 = axes;
imshow(I,'Parent',ax1) % Show the image on ax1
plot(ax2,magic(4)) % Plot the data on ax2
ax2.Color = 'none'; % Set background color of ax2 to transparent
koji fukumoto
koji fukumoto el 3 de Dic. de 2019
「axes を2つ重ねて」の方法で実現できました。
迅速なご回答、ありがとうございました。

Iniciar sesión para comentar.

Más respuestas (1)

yuji Ito
yuji Ito el 30 de Jun. de 2020

0 votos

AppDesignerのplotウインドウで上記の様なことをしたいのですが、
ax1,ax2と2つの軸を作ることが出来ず、上記ではうまくいきません。
AppDesingerで同様のことを実現する方法はないでしょうか?

Categorías

Productos

Versión

R2018a

Etiquetas

Preguntada:

el 3 de Dic. de 2019

Respondida:

el 30 de Jun. de 2020

Community Treasure Hunt

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

Start Hunting!