Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
dòng chảy căng:: ôi:: Giải mãPng
#include <image_ops.h>
Giải mã hình ảnh được mã hóa PNG thành tenxơ uint8 hoặc uint16.
Bản tóm tắt
channels
attr cho biết số lượng kênh màu mong muốn cho hình ảnh được giải mã.
Các giá trị được chấp nhận là:
- 0: Sử dụng số kênh trong hình ảnh được mã hóa PNG.
- 1: xuất ra hình ảnh thang độ xám.
- 3: xuất hình ảnh RGB.
- 4: xuất hình ảnh RGBA.
Nếu cần, hình ảnh được mã hóa PNG sẽ được chuyển đổi để phù hợp với số lượng kênh màu được yêu cầu.
Hoạt động này cũng hỗ trợ giải mã JPEG và GIF không hoạt hình vì giao diện giống nhau, mặc dù sử dụng tf.image.decode_image
sẽ sạch hơn.
Lập luận:
- phạm vi: Một đối tượng Phạm vi
- nội dung: 0-D. Hình ảnh được mã hóa PNG.
Thuộc tính tùy chọn (xem Attrs
):
- kênh: Số lượng kênh màu cho hình ảnh được giải mã.
Trả về:
-
Output
: 3-D với hình dạng [height, width, channels]
.
Thuộc tính công khai
Chức năng công cộng
nút
::tensorflow::Node * node() const
operator::tensorflow::Input() const
toán tử::tenorflow::Đầu ra
operator::tensorflow::Output() const
Các hàm tĩnh công khai
Kênh
Attrs Channels(
int64 x
)
loại D
Attrs Dtype(
DataType x
)
Trừ phi có lưu ý khác, nội dung của trang này được cấp phép theo Giấy phép ghi nhận tác giả 4.0 của Creative Commons và các mẫu mã lập trình được cấp phép theo Giấy phép Apache 2.0. Để biết thông tin chi tiết, vui lòng tham khảo Chính sách trang web của Google Developers. Java là nhãn hiệu đã đăng ký của Oracle và/hoặc các đơn vị liên kết với Oracle.
Cập nhật lần gần đây nhất: 2025-07-26 UTC.
[null,null,["Cập nhật lần gần đây nhất: 2025-07-26 UTC."],[],[],null,["# tensorflow::ops::DecodePng Class Reference\n\ntensorflow::ops::DecodePng\n==========================\n\n`#include \u003cimage_ops.h\u003e`\n\nDecode a PNG-encoded image to a uint8 or uint16 tensor.\n\nSummary\n-------\n\nThe attr `channels` indicates the desired number of color channels for the decoded image.\n\nAccepted values are:\n\n\n- 0: Use the number of channels in the PNG-encoded image.\n- 1: output a grayscale image.\n- 3: output an RGB image.\n- 4: output an RGBA image.\n\n\u003cbr /\u003e\n\nIf needed, the PNG-encoded image is transformed to match the requested number of color channels.\n\nThis op also supports decoding JPEGs and non-animated GIFs since the interface is the same, though it is cleaner to use `tf.image.decode_image`.\n\nArguments:\n\n- scope: A [Scope](/versions/r1.15/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope) object\n- contents: 0-D. The PNG-encoded image.\n\n\u003cbr /\u003e\n\nOptional attributes (see [Attrs](/versions/r1.15/api_docs/cc/struct/tensorflow/ops/decode-png/attrs#structtensorflow_1_1ops_1_1_decode_png_1_1_attrs)):\n\n- channels: Number of color channels for the decoded image.\n\n\u003cbr /\u003e\n\nReturns:\n\n- [Output](/versions/r1.15/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output): 3-D with shape `[height, width, channels]`.\n\n\u003cbr /\u003e\n\n| ### Constructors and Destructors ||\n|---|---|\n| [DecodePng](#classtensorflow_1_1ops_1_1_decode_png_1ab7adeeb5aa6b10893fb6063ee8d6fc87)`(const ::`[tensorflow::Scope](/versions/r1.15/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope)` & scope, ::`[tensorflow::Input](/versions/r1.15/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` contents)` ||\n| [DecodePng](#classtensorflow_1_1ops_1_1_decode_png_1aa2df55e8e1eed056df69f127ca4cba25)`(const ::`[tensorflow::Scope](/versions/r1.15/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope)` & scope, ::`[tensorflow::Input](/versions/r1.15/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` contents, const `[DecodePng::Attrs](/versions/r1.15/api_docs/cc/struct/tensorflow/ops/decode-png/attrs#structtensorflow_1_1ops_1_1_decode_png_1_1_attrs)` & attrs)` ||\n\n| ### Public attributes ||\n|----------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------|\n| [image](#classtensorflow_1_1ops_1_1_decode_png_1a493e0f58c502e83895b5ab8df3ed277c) | `::`[tensorflow::Output](/versions/r1.15/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output) |\n| [operation](#classtensorflow_1_1ops_1_1_decode_png_1ac11da6e89a194ee86e7a82442fb33ed4) | [Operation](/versions/r1.15/api_docs/cc/class/tensorflow/operation#classtensorflow_1_1_operation) |\n\n| ### Public functions ||\n|----------------------------------------------------------------------------------------------------------------------|------------------------|\n| [node](#classtensorflow_1_1ops_1_1_decode_png_1adea6247b44969accb1513a6b237bd2d3)`() const ` | `::tensorflow::Node *` |\n| [operator::tensorflow::Input](#classtensorflow_1_1ops_1_1_decode_png_1a1449fe5081528b4cb081cb224ba20d96)`() const ` | ` ` ` ` |\n| [operator::tensorflow::Output](#classtensorflow_1_1ops_1_1_decode_png_1a19025343d7746c9091afcf01dbba03fd)`() const ` | ` ` ` ` |\n\n| ### Public static functions ||\n|--------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------|\n| [Channels](#classtensorflow_1_1ops_1_1_decode_png_1ac0322c095dfd2d11bca81c46b421847a)`(int64 x)` | [Attrs](/versions/r1.15/api_docs/cc/struct/tensorflow/ops/decode-png/attrs#structtensorflow_1_1ops_1_1_decode_png_1_1_attrs) |\n| [Dtype](#classtensorflow_1_1ops_1_1_decode_png_1a656dedb17c75247c916d54efef9fb4f6)`(DataType x)` | [Attrs](/versions/r1.15/api_docs/cc/struct/tensorflow/ops/decode-png/attrs#structtensorflow_1_1ops_1_1_decode_png_1_1_attrs) |\n\n| ### Structs ||\n|---------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------|\n| [tensorflow::ops::DecodePng::Attrs](/versions/r1.15/api_docs/cc/struct/tensorflow/ops/decode-png/attrs) | Optional attribute setters for [DecodePng](/versions/r1.15/api_docs/cc/class/tensorflow/ops/decode-png#classtensorflow_1_1ops_1_1_decode_png). |\n\nPublic attributes\n-----------------\n\n### image\n\n```text\n::tensorflow::Output image\n``` \n\n### operation\n\n```text\nOperation operation\n``` \n\nPublic functions\n----------------\n\n### DecodePng\n\n```gdscript\n DecodePng(\n const ::tensorflow::Scope & scope,\n ::tensorflow::Input contents\n)\n``` \n\n### DecodePng\n\n```gdscript\n DecodePng(\n const ::tensorflow::Scope & scope,\n ::tensorflow::Input contents,\n const DecodePng::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### Channels\n\n```text\nAttrs Channels(\n int64 x\n)\n``` \n\n### Dtype\n\n```carbon\nAttrs Dtype(\n DataType x\n)\n```"]]