Main Content

このページの内容は最新ではありません。最新版の英語を参照するには、ここをクリックします。

ピクセル領域ツールの作成

この例では、別の Figure ウィンドウにピクセル領域ツールを作成し、既存の Figure ウィンドウに組み込む方法を説明します。

別の Figure ウィンドウへのピクセル領域ツールの作成

イメージをワークスペースに読み取ります。

I = imread("pout.tif");

イメージを Figure ウィンドウに表示します。ターゲット イメージ himage のハンドルを返します。

himage = imshow('pout.tif');

別のウィンドウにピクセル領域ツールを作成するには、関数 impixelregion を使用します。

hpixreg = impixelregion(himage);

Figure contains an axes object. The axes object contains 12 objects of type line, patch, image.

Figure Pixel Region (Figure 1) contains an axes object and other objects of type uipanel, uitoolbar, uimenu. The axes object contains 75 objects of type line, image, text.

既存の Figure へのピクセル領域ツールの組み込み

新しい Figure ウィンドウを作成して、figure のハンドルを返します。

fig = figure;

axes を作成して、axes 内でターゲット イメージを表示します。

ax = axes;
img = imshow(I);

ターゲット イメージと同じ Figure にピクセル領域ツールを作成するには、関数 impixelregionpanel を使用します。ターゲット イメージの親 Figure である fig をピクセル領域ツールの親として指定します。

pixregionobj = impixelregionpanel(fig,img);

Figure contains 2 axes objects and another object of type uipanel. Axes object 1 contains 137 objects of type line, image, text. Axes object 2 contains 12 objects of type line, patch, image.

ピクセル領域ツールが重なって表示され、元のイメージが表示されなくなります。イメージとツールの両方を表示するには、それらが重ならないように位置を移動させます。

set(ax,'Units','normalized','Position',[0 .5 1 .5]);
set(pixregionobj,'Units','normalized','Position',[0 .04 1 .4]);

Figure contains 2 axes objects and another object of type uipanel. Axes object 1 contains 65 objects of type line, image, text. Axes object 2 contains 12 objects of type line, patch, image.

参考

|

関連するトピック