cv2.imread() from 16-bit TIFF creates arrays where np.maximum() fails in function context but works directly
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 35/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 静か
- 技術スタック
- numpy, python
調査の方向性
まず、報告されている Python、OpenCV、NumPy のバージョンで、添付された 0000.tif を使って test_cv2_issue.py を実行し、その後、直接実行した np.maximum() の結果と関数コンテキスト内での結果を比較します。コンテキスト依存の失敗を再現し、その範囲または原因を特定したうえで、HLS の色相結果と配列レイアウトを報告と照合できれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Environment (fill in your exact versions):
- Platform: macOS-15.6.1 (arm64)
- Python 3.14.2
- OpenCV: 4.11.0
- NumPy: 2.2.6
Bug Description:
- cv2.imread() with 16-bit TIFF files creates float32 arrays that cause np.maximum() and np.minimum() to behave inconsistently. When these numpy functions are called inside another function, they return incorrect values, but when called directly on the same arrays, they work correctly.
Key Symptoms:
- Context-dependent failure: np.maximum() works when called directly, fails when called inside functions
- Incorrect HLS conversion: Causes hue channel (H) to be 0 instead of ≈46.6
- Array properties: Non-C-contiguous (strides: (24000, 12) for 1300×2000 image)
- Specific to: Photoshop-created 16-bit TIFFs (random syntetic TIFFs generated by CV2 don't trigger bug)
Impact:
- Any image processing using np.maximum()/np.minimum() on OpenCV-loaded float32 arrays in functions produces wrong results.
Workaround:
- Use Python's max()/min() instead of np.maximum()/np.minimum(). But it is extremely slower for large images.
The bug does not show up with python 3.12.
In attachment a sample image and the script that allows to reproduce the bug.
- 主要言語
- Python
- スター
- 5.4k
- フォーク
- 1k
- 平均マージ
- 22時間 17分
- マージ済み PR(30日)
- 3
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
opencv/opencv-python のほかの issue
-
[DOC] README file オープン
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
opencv/opencv-python#1217 · コメント 3 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
opencv/opencv-python#1165 · コメント 2 件 · リアクション 1 件 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
opencv/opencv-python#1273 · コメント 1 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
opencv/opencv-python#1272 · コメント 1 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 70/100
opencv/opencv-python#1268 · コメント 1 件 ·
opencv/opencv-python の issue をすべて見る
似ている issue
-
agent-ready documentation needs-triage
難易度 1/5 1〜3時間 初心者へのやさしさ 88/100
-
documentation
難易度 1/5 1時間未満 初心者へのやさしさ 91/100
-
workflow-status page template still says reusable workflows are "triggered only by workflow_call:" オープン
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
-
instance instance add
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
searxng/searx-instances#939 · コメント 1 件 ·
-
area-deployment area-integrations triage:bot-seen
難易度 2/5 半日 初心者へのやさしさ 86/100