このページの内容は最新ではありません。最新版の英語を参照するには、ここをクリックします。
crop
説明
例
多重解像度イメージのトリミング
ツールボックスに含まれるサンプル イメージから、ブロック化されたイメージを作成します。
bim = blockedImage('tumor_091R.tif');
figure
bigimageshow(bim);
イメージ サイズとワールド座標のプロパティを検証します。
bim.Size
ans = 3×3
5000 5358 3
1250 1340 3
625 670 3
bim.WorldStart
ans = 3×3
0.5000 0.5000 0.5000
0.5000 0.5000 0.5000
0.5000 0.5000 0.5000
bim.WorldEnd
ans = 3×3
103 ×
5.0005 5.3585 0.0035
5.0005 5.3585 0.0035
5.0005 5.3585 0.0035
トリミング領域となる関心領域をイメージ上で定義します。
hrect = drawrectangle('Position', [2280 1300 1024 800]);
領域のワールド座標を取得します。
wstartxy = hrect.Position(1:2); wendxy = wstartxy + hrect.Position(3:4);
最後の次元であるワールド座標を含め、行と列の並びに変換します。
wstart = [wstartxy(2), wstartxy(1), bim.WorldStart(1,3)]; wend = [wendxy(2), wendxy(1), bim.WorldEnd(1,3)];
イメージの添字に変換します。このステップはオプションですが、既定以外のワールド座標を使用する場合に役立ちます。
subs = world2sub(bim, [wstart; wend]); cbim = crop(bim, subs(1,:), subs(2,:));
トリミングしたイメージのプロパティを検証します。
cbim.Size
ans = 3×3
801 1025 3
201 258 3
101 130 3
cbim.WorldStart
ans = 3×3
103 ×
1.2995 2.2795 0.0005
1.2965 2.2757 0.0005
1.2965 2.2717 0.0005
figure
% Axes limits reflect cropped coordinates
bigimageshow(cbim);
入力引数
bim
— ブロック化されたイメージ
blockedImage
オブジェクト
ブロック化されたイメージ。blockedImage
オブジェクトとして指定します。
cstart
— トリミング ウィンドウの最初のピクセル
1 行 N 列の整数値のベクトル
ピクセルの添字で表された、トリミング ウィンドウの最初のピクセル。N 次元の blockedImage
について、1 行 N 列の整数値のベクトルとして指定します。cstart
の要素が N 個より少ない場合、blockedImage
は 1 を使ってイメージを拡張します。
cend
— トリミング ウィンドウの最後のピクセル
1 行 N 列の整数値のベクトル
ピクセルの添字で表された、トリミング ウィンドウの最後のピクセル。1 行 N 列の整数値のベクトルとして指定します。cend
の要素が N 個より少ない場合、blockedImage
は、最も細かい解像度レベルの Size
に対応する要素でイメージを拡張します。
出力引数
cbim
— トリミング済みのブロック化されたイメージ
blockedImage
オブジェクト
トリミング済みのブロック化されたイメージ。トリミング ウィンドウに含まれるすべての解像度レベルのイメージ データを含む blockedImage
オブジェクトとして返されます。
バージョン履歴
R2021a で導入
MATLAB コマンド
次の MATLAB コマンドに対応するリンクがクリックされました。
コマンドを MATLAB コマンド ウィンドウに入力して実行してください。Web ブラウザーは MATLAB コマンドをサポートしていません。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)