How to create a TIFF file with JPEG compression, JPEG2000 compression, or other compression methods in Python?

未關閉
#41 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

評估

難度
3/5
預估耗時
1-2 天
新手友好度
35/100
Issue 類型
文件
描述清晰度
需要釐清
活躍度
停滯
技術堆疊
python

研究方向

先從連結的 Python 範例和 Python API 參考開始,接著追蹤 issue 中展示的 EncodeParams 用法。確認文件所述的 API 是否涵蓋所要求的 TIFF 壓縮方法,並為 Python 使用者清楚說明受支援的程序和限制。

由索引模型根據 Issue 內容生成。

描述

question
Describe the question.

Hello, thank you for viewing this question. I need to create some TIFF files with JPEG or JPEG2000 compression. After learning about nvImageCodec, I tried to study it. However, I couldn't find suitable answers in the official documentation at https://docs.nvidia.com/cuda/nvimagecodec/samples/python_samples.html and https://docs.nvidia.com/cuda/nvimagecodec/py_api.html . Since I don't know how to write C or C++ code, I came here to ask. Thank you for your help.

Here is my Python code snippet:


import numpy as np
from nvidia import nvimgcodec



tif_file = r"HH_2.tiff"
# The image is 8-bit with 3 channels.

decodeparams = nvimgcodec.DecodeParams(allow_any_depth=True)

decoder = nvimgcodec.Decoder()

nv_img_0 = decoder.decode(tif_file, params=decodeparams)

img_0 = np.array(nv_img_0.cpu())


encoder = nvimgcodec.Encoder()

codec = 'tiff'
encode_params_0 = nvimgcodec.EncodeParams(quality_type=nvimgcodec.QualityType.LOSSLESS)

encoder.write("HH_nv.tiff", img_0, codec, params=encode_params_0)
# It outputs an uncompressed TIFF image.

encode_params_1 = nvimgcodec.EncodeParams(quality_value=1)

encoder.write("HH_LZW_nv.tiff", img_0, codec, params=encode_params_1)
# The output is a TIFF image compressed with LZW.

Check for duplicates
  • I have searched the open bugs/issues and have found no duplicates for this bug report
主要語言
Jupyter Notebook
星號
164
分支
26
平均合併
27 分鐘
30 天內合併 PR
1

環境準備

  • 沒有 Dockerfile 或 Docker Compose 檔案
  • 沒有 Pull Request 範本
  • 閱讀貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

NVIDIA/nvImageCodec 的其他 Issue

查看 NVIDIA/nvImageCodec 的全部 Issue

相似的 Issue

更多 Computer Vision Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。