cv2.imread() from 16-bit TIFF creates arrays where np.maximum() fails in function context but works directly
还没有人认领这个 Issue。
评估
- 难度
- 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 分钟
- 30 天内合并 PR
- 3
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
opencv/opencv-python 的其他 Issue
-
难度 1/5 1 小时以内 新手友好度 85/100
opencv/opencv-python#1217 · 3 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 72/100
opencv/opencv-python#1165 · 2 条评论 · 1 个 reaction ·
-
难度 5/5 一周以上 新手友好度 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
-
area: harness bug status: needs-triage
难度 2/5 1-3 小时 新手友好度 75/100
Human-Agent-Society/reef#625 ·
-
难度 2/5 1-3 小时 新手友好度 70/100
-
难度 1/5 1 小时以内 新手友好度 80/100
learningequality/kolibri#15351 · 2 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
-
Name consistency 未关闭
难度 2/5 1-3 小时 新手友好度 75/100
eellak/triplestore#65 · 1 条评论 ·