컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
텐서플로우:: 작전:: 자르기 및 크기 조정
#include <image_ops.h>
입력 이미지 텐서에서 자르기를 추출하고 크기를 조정합니다.
요약
입력 이미지 텐서에서 자르기를 추출하고 쌍선형 샘플링 또는 가장 가까운 이웃 샘플링(종횡비 변경 가능)을 사용하여 crop_size
에 지정된 공통 출력 크기로 크기를 조정합니다. 이는 입력 이미지에서 고정 크기 슬라이스를 추출하고 크기 조정이나 종횡비 변경을 허용하지 않는 crop_to_bounding_box
작업보다 더 일반적입니다.
boxes
의 경계 상자 위치에 정의된 위치에서 입력 image
의 crops
포함하는 텐서를 반환합니다. 잘린 상자는 모두 고정된 size = [crop_height, crop_width]
로 크기가 조정됩니다(이선형 또는 최근접 이웃 보간 사용). 결과는 4차원 텐서 [num_boxes, crop_height, crop_width, depth]
입니다. 크기 조정은 모서리에 맞춰집니다. 특히, boxes = [[0, 0, 1, 1]]
인 경우 이 메소드는 align_corners=True
와 함께 tf.image.resize_bilinear()
또는 tf.image.resize_nearest_neighbor()
( method
인수에 따라 다름)를 사용하는 것과 동일한 결과를 제공합니다. align_corners=True
.
인수:
- 범위: 범위 개체
- image:
[batch, image_height, image_width, depth]
모양의 4차원 텐서. image_height
와 image_width
모두 양수여야 합니다. - 상자:
[num_boxes, 4]
모양의 2차원 텐서. 텐서의 i
번째 행은 box_ind[i]
이미지의 상자 좌표를 지정하고 정규화된 좌표 [y1, x1, y2, x2]
로 지정됩니다. y
의 정규화된 좌표 값은 y * (image_height - 1)
의 이미지 좌표에 매핑되므로 정규화된 이미지 높이의 [0, 1]
간격은 이미지 높이 좌표에서 [0, image_height - 1]
에 매핑됩니다. y1
> y2
허용합니다. 이 경우 샘플링된 자르기는 원본 이미지를 위아래로 뒤집은 버전입니다. 너비 치수도 유사하게 처리됩니다. [0, 1]
범위 밖의 정규화된 좌표가 허용되며, 이 경우 extrapolation_value
사용하여 입력 이미지 값을 추정합니다. - box_ind:
[0, batch)
에 int32 값을 갖는 [num_boxes]
모양의 1차원 텐서. box_ind[i]
의 값은 i
번째 상자가 참조하는 이미지를 지정합니다. - Crop_size: 2개 요소로 구성된 1차원 텐서,
size = [crop_height, crop_width]
. 잘린 이미지 패치는 모두 이 크기로 조정됩니다. 이미지 콘텐츠의 종횡비는 유지되지 않습니다. crop_height
와 crop_width
모두 양수여야 합니다.
선택적 속성( Attrs
참조):
- method: 크기 조정을 위한 샘플링 방법을 지정하는 문자열입니다.
"bilinear"
또는 "nearest"
일 수 있으며 기본값은 "bilinear"
입니다. 현재 Bilinear와 Nearest Neighbor라는 두 가지 샘플링 방법이 지원됩니다. - extrapolation_value: 적용 가능한 경우 외삽에 사용되는 값입니다.
보고:
-
Output
: [num_boxes, crop_height, crop_width, depth]
모양의 4D 텐서.
공개 속성
공공 기능
마디
::tensorflow::Node * node() const
operator::tensorflow::Input() const
연산자::텐서플로우::출력
operator::tensorflow::Output() const
공개 정적 함수
Attrs ExtrapolationValue(
float x
)
방법
Attrs Method(
StringPiece x
)
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2025-07-26(UTC)
[null,null,["최종 업데이트: 2025-07-26(UTC)"],[],[],null,["# tensorflow::ops::CropAndResize Class Reference\n\ntensorflow::ops::CropAndResize\n==============================\n\n`#include \u003cimage_ops.h\u003e`\n\nExtracts crops from the input image tensor and resizes them.\n\nSummary\n-------\n\nExtracts crops from the input image tensor and resizes them using bilinear sampling or nearest neighbor sampling (possibly with aspect ratio change) to a common output size specified by `crop_size`. This is more general than the `crop_to_bounding_box` op which extracts a fixed size slice from the input image and does not allow resizing or aspect ratio change.\n\nReturns a tensor with `crops` from the input `image` at positions defined at the bounding box locations in `boxes`. The cropped boxes are all resized (with bilinear or nearest neighbor interpolation) to a fixed `size = [crop_height, crop_width]`. The result is a 4-D tensor `[num_boxes, crop_height, crop_width, depth]`. The resizing is corner aligned. In particular, if `boxes = [[0, 0, 1, 1]]`, the method will give identical results to using `tf.image.resize_bilinear()` or `tf.image.resize_nearest_neighbor()`(depends on the `method` argument) with `align_corners=True`.\n\nArguments:\n\n- scope: A [Scope](/versions/r2.3/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope) object\n- image: A 4-D tensor of shape `[batch, image_height, image_width, depth]`. Both `image_height` and `image_width` need to be positive.\n- boxes: A 2-D tensor of shape `[num_boxes, 4]`. The `i`-th row of the tensor specifies the coordinates of a box in the `box_ind[i]` image and is specified in normalized coordinates `[y1, x1, y2, x2]`. A normalized coordinate value of `y` is mapped to the image coordinate at `y * (image_height - 1)`, so as the `[0, 1]` interval of normalized image height is mapped to `[0, image_height - 1]` in image height coordinates. We do allow `y1` \\\u003e `y2`, in which case the sampled crop is an up-down flipped version of the original image. The width dimension is treated similarly. Normalized coordinates outside the `[0, 1]` range are allowed, in which case we use `extrapolation_value` to extrapolate the input image values.\n- box_ind: A 1-D tensor of shape `[num_boxes]` with int32 values in `[0, batch)`. The value of `box_ind[i]` specifies the image that the `i`-th box refers to.\n- crop_size: A 1-D tensor of 2 elements, `size = [crop_height, crop_width]`. [All](/versions/r2.3/api_docs/cc/class/tensorflow/ops/all#classtensorflow_1_1ops_1_1_all) cropped image patches are resized to this size. The aspect ratio of the image content is not preserved. Both `crop_height` and `crop_width` need to be positive.\n\n\u003cbr /\u003e\n\nOptional attributes (see [Attrs](/versions/r2.3/api_docs/cc/struct/tensorflow/ops/crop-and-resize/attrs#structtensorflow_1_1ops_1_1_crop_and_resize_1_1_attrs)):\n\n- method: A string specifying the sampling method for resizing. It can be either `\"bilinear\"` or `\"nearest\"` and default to `\"bilinear\"`. Currently two sampling methods are supported: Bilinear and Nearest Neighbor.\n- extrapolation_value: Value used for extrapolation, when applicable.\n\n\u003cbr /\u003e\n\nReturns:\n\n- [Output](/versions/r2.3/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output): A 4-D tensor of shape `[num_boxes, crop_height, crop_width, depth]`.\n\n\u003cbr /\u003e\n\n| ### Constructors and Destructors ||\n|---|---|\n| [CropAndResize](#classtensorflow_1_1ops_1_1_crop_and_resize_1ab17f07d2b9db2923f4f16cc6ddd10c9d)`(const ::`[tensorflow::Scope](/versions/r2.3/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope)` & scope, ::`[tensorflow::Input](/versions/r2.3/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` image, ::`[tensorflow::Input](/versions/r2.3/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` boxes, ::`[tensorflow::Input](/versions/r2.3/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` box_ind, ::`[tensorflow::Input](/versions/r2.3/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` crop_size)` ||\n| [CropAndResize](#classtensorflow_1_1ops_1_1_crop_and_resize_1adb1d93c1c956c1d654b701bc078ab6ae)`(const ::`[tensorflow::Scope](/versions/r2.3/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope)` & scope, ::`[tensorflow::Input](/versions/r2.3/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` image, ::`[tensorflow::Input](/versions/r2.3/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` boxes, ::`[tensorflow::Input](/versions/r2.3/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` box_ind, ::`[tensorflow::Input](/versions/r2.3/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` crop_size, const `[CropAndResize::Attrs](/versions/r2.3/api_docs/cc/struct/tensorflow/ops/crop-and-resize/attrs#structtensorflow_1_1ops_1_1_crop_and_resize_1_1_attrs)` & attrs)` ||\n\n| ### Public attributes ||\n|---------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------|\n| [crops](#classtensorflow_1_1ops_1_1_crop_and_resize_1a3d1569c38bfdd7881539d76880193614) | `::`[tensorflow::Output](/versions/r2.3/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output) |\n| [operation](#classtensorflow_1_1ops_1_1_crop_and_resize_1ade78876fbd90696b4364af105b775c29) | [Operation](/versions/r2.3/api_docs/cc/class/tensorflow/operation#classtensorflow_1_1_operation) |\n\n| ### Public functions ||\n|---------------------------------------------------------------------------------------------------------------------------|------------------------|\n| [node](#classtensorflow_1_1ops_1_1_crop_and_resize_1a44e6253b604ef5a11098dd6b01034a73)`() const ` | `::tensorflow::Node *` |\n| [operator::tensorflow::Input](#classtensorflow_1_1ops_1_1_crop_and_resize_1a009f32b1c13c815bcb4f1e20bbb506d9)`() const ` | ` ` ` ` |\n| [operator::tensorflow::Output](#classtensorflow_1_1ops_1_1_crop_and_resize_1a27ee3121d018ca29ecc4d112bfe6dbf7)`() const ` | ` ` ` ` |\n\n| ### Public static functions ||\n|-----------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------|\n| [ExtrapolationValue](#classtensorflow_1_1ops_1_1_crop_and_resize_1a24585f2ae8f486ed7cf26b7636398bbb)`(float x)` | [Attrs](/versions/r2.3/api_docs/cc/struct/tensorflow/ops/crop-and-resize/attrs#structtensorflow_1_1ops_1_1_crop_and_resize_1_1_attrs) |\n| [Method](#classtensorflow_1_1ops_1_1_crop_and_resize_1a430830e07a336ae16aa3093ed0480d8d)`(StringPiece x)` | [Attrs](/versions/r2.3/api_docs/cc/struct/tensorflow/ops/crop-and-resize/attrs#structtensorflow_1_1ops_1_1_crop_and_resize_1_1_attrs) |\n\n| ### Structs ||\n|-----------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [tensorflow::ops::CropAndResize::Attrs](/versions/r2.3/api_docs/cc/struct/tensorflow/ops/crop-and-resize/attrs) | Optional attribute setters for [CropAndResize](/versions/r2.3/api_docs/cc/class/tensorflow/ops/crop-and-resize#classtensorflow_1_1ops_1_1_crop_and_resize). |\n\nPublic attributes\n-----------------\n\n### crops\n\n```text\n::tensorflow::Output crops\n``` \n\n### operation\n\n```text\nOperation operation\n``` \n\nPublic functions\n----------------\n\n### CropAndResize\n\n```gdscript\n CropAndResize(\n const ::tensorflow::Scope & scope,\n ::tensorflow::Input image,\n ::tensorflow::Input boxes,\n ::tensorflow::Input box_ind,\n ::tensorflow::Input crop_size\n)\n``` \n\n### CropAndResize\n\n```gdscript\n CropAndResize(\n const ::tensorflow::Scope & scope,\n ::tensorflow::Input image,\n ::tensorflow::Input boxes,\n ::tensorflow::Input box_ind,\n ::tensorflow::Input crop_size,\n const CropAndResize::Attrs & attrs\n)\n``` \n\n### node\n\n```gdscript\n::tensorflow::Node * node() const \n``` \n\n### operator::tensorflow::Input\n\n```gdscript\n operator::tensorflow::Input() const \n``` \n\n### operator::tensorflow::Output\n\n```gdscript\n operator::tensorflow::Output() const \n``` \n\nPublic static functions\n-----------------------\n\n### ExtrapolationValue\n\n```text\nAttrs ExtrapolationValue(\n float x\n)\n``` \n\n### Method\n\n```text\nAttrs Method(\n StringPiece x\n)\n```"]]