Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

cv2.imread() from 16-bit TIFF creates arrays where np.maximum() fails in function context but works directly

Aperta
#1,182 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
numpy, python

Direzione di ricerca

Inizia eseguendo test_cv2_issue.py con il file 0000.tif allegato usando le versioni di Python, OpenCV e NumPy indicate, quindi confronta i risultati diretti di np.maximum() con quelli nel contesto di una funzione. Il lavoro è completato quando il malfunzionamento dipendente dal contesto è stato riprodotto e ne sono stati stabiliti l’ambito o la causa, verificando il risultato della tonalità HLS e la disposizione dell’array rispetto alla segnalazione.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

test_cv2_issue.py

0000.tif

Lingua principale
Python
Stelle
5.4k
Fork
1k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di opencv/opencv-python

Tutte le issue di opencv/opencv-python

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.