0

私は 2 つのビューで構成される matlab アプリケーションを作成しました。それぞれが他方のハンドルを認識しています。メイン ビューは 2 番目のビューを起動し、そのハンドルを取得します。

次に、関数subplot()がメイン ビューで呼び出され、 を使用して画像が表示されますimshow()。私がやりたいことは、subplot()およびimshow()関数を使用して、画像のいくつかの詳細を 2 番目のビューに表示することです。

2 番目のビューのハンドルを使用して、メイン ビューから 2 番目のビューで定義された関数を呼び出します。この関数は、詳細についてはさらに subplot() とimshow()関数を呼び出します。

何が起こるかというと、メイン ビューの最初のイメージが消えて、詳細に置き換えられます。詳細が2番目のビューに表示されている間、メインビューに画像を表示できるように、誰かにアドバイスをもらえますか?

4

1 に答える 1

0

Maybe you need to specify the axis in which you are placing your image or data. The imshow command allows you specify the axes to use for displaying images with the Parent parameter.

Combine this with the fact that subplot returns a handle to the axis it creates and you have.

h = subplot(m,n,i) %# create a subplot axes
imshow(img,'Parent',h) %# display an image in the previously created axis

Assuming you can pass information between the two sets of code you would need to retrieve the handle to the axis you want the image to show up in and use that handle in the call to imshow. Here is an example

hFig = figure;
h(1) = subplot(2,2,1)
h(2) = subplot(2,2,2)
setappdata(hFig,'axisHandles',h) %# stores the axes handles in appdata of the figure
....

Now when you want to show some an image in the first figure you can do the following assuming you know the handle to each of your figure windows.

h=getappdata(hFig,'axisHandles')
imshow(img,'Parent',h(1))
于 2012-07-11T22:34:45.100 に答える