1 | /**
|
2 | * @license
|
3 | * Copyright 2020 Google LLC. All Rights Reserved.
|
4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | * you may not use this file except in compliance with the License.
|
6 | * You may obtain a copy of the License at
|
7 | *
|
8 | * http://www.apache.org/licenses/LICENSE-2.0
|
9 | *
|
10 | * Unless required by applicable law or agreed to in writing, software
|
11 | * distributed under the License is distributed on an "AS IS" BASIS,
|
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13 | * See the License for the specific language governing permissions and
|
14 | * limitations under the License.
|
15 | * =============================================================================
|
16 | */
|
17 | /// <amd-module name="@tensorflow/tfjs-core/dist/ops/image/crop_and_resize" />
|
18 | import { Tensor1D, Tensor2D, Tensor4D } from '../../tensor';
|
19 | import { TensorLike } from '../../types';
|
20 | /**
|
21 | * Extracts crops from the input image tensor and resizes them using bilinear
|
22 | * sampling or nearest neighbor sampling (possibly with aspect ratio change)
|
23 | * to a common output size specified by cropSize.
|
24 | *
|
25 | * @param image 4d tensor of shape `[batch,imageHeight,imageWidth, depth]`,
|
26 | * where imageHeight and imageWidth must be positive, specifying the
|
27 | * batch of images from which to take crops
|
28 | * @param boxes 2d float32 tensor of shape `[numBoxes, 4]`. Each entry is
|
29 | * `[y1, x1, y2, x2]`, where `(y1, x1)` and `(y2, x2)` are the normalized
|
30 | * coordinates of the box in the boxInd[i]'th image in the batch
|
31 | * @param boxInd 1d int32 tensor of shape `[numBoxes]` with values in range
|
32 | * `[0, batch)` that specifies the image that the `i`-th box refers to.
|
33 | * @param cropSize 1d int32 tensor of 2 elements `[cropHeigh, cropWidth]`
|
34 | * specifying the size to which all crops are resized to.
|
35 | * @param method Optional string from `'bilinear' | 'nearest'`,
|
36 | * defaults to bilinear, which specifies the sampling method for resizing
|
37 | * @param extrapolationValue A threshold for deciding when to remove boxes based
|
38 | * on score. Defaults to 0.
|
39 | * @return A 4D tensor of the shape `[numBoxes,cropHeight,cropWidth,depth]`
|
40 | *
|
41 | * @doc {heading: 'Operations', subheading: 'Images', namespace: 'image'}
|
42 | */
|
43 | declare function cropAndResize_(image: Tensor4D | TensorLike, boxes: Tensor2D | TensorLike, boxInd: Tensor1D | TensorLike, cropSize: [number, number], method?: 'bilinear' | 'nearest', extrapolationValue?: number): Tensor4D;
|
44 | export declare const cropAndResize: typeof cropAndResize_;
|
45 | export {};
|