Image conversion should scale pixel values accordingly
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 42/100
- Type d'issue
- Bug
- Clarté
- Plutôt claire
- Activité
- À l'abandon
- Stack technique
- python
- Domaine
- computer-graphics
Piste de recherche
No source file or test is named. Reproduce the reported conversions from 16-bit and floating-point grayscale images to 'L', then trace Pillow's image-mode conversion entry points; done means values are scaled to the destination range rather than clamped, with coverage for the examples shown.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
What did you do?
I tried to convert grayscale images of different modes together
What did you expect to happen?
Conversion should scale values; for example, converting from float to 8-bit should have the values scaled by 255, converting from 8-bit to 16-bit should have the values scaled by 65535/255, etc.
What actually happened?
Values are being clamped
>>> img = Image.open('16bit_image.png')
>>> img.mode
'I'
>>> numpy.array(img)
array([[51559, 52726, 50875, ..., 30493, 30991, 29907],
[51743, 52185, 51221, ..., 30841, 29920, 30793],
[51279, 50534, 51128, ..., 31532, 30852, 30651],
...,
[28288, 27868, 28032, ..., 34367, 34235, 34312],
[26900, 27567, 28120, ..., 36229, 34607, 33399],
[27966, 28224, 27962, ..., 36223, 35851, 34477]], dtype=int32)
>>> numpy.array(img.convert('L'))
array([[255, 255, 255, ..., 255, 255, 255],
[255, 255, 255, ..., 255, 255, 255],
[255, 255, 255, ..., 255, 255, 255],
...,
[255, 255, 255, ..., 255, 255, 255],
[255, 255, 255, ..., 255, 255, 255],
[255, 255, 255, ..., 255, 255, 255]], dtype=uint8)
Floating point data really doesn't go over well either
>>> img_float = Image.fromarray(numpy.divide(numpy.array(img), 2**16-1))
>>> numpy.array(img_float)
array([[0.7867399 , 0.8045472 , 0.77630275, ..., 0.46529335, 0.47289234,
0.45635158],
[0.78954756, 0.79629207, 0.78158236, ..., 0.4706035 , 0.45654994,
0.46987107],
[0.78246737, 0.7710994 , 0.7801633 , ..., 0.48114747, 0.47077134,
0.46770427],
...,
[0.4316472 , 0.42523843, 0.4277409 , ..., 0.5244068 , 0.52239263,
0.52356756],
[0.41046768, 0.42064545, 0.4290837 , ..., 0.55281913, 0.52806896,
0.50963604],
[0.4267338 , 0.43067065, 0.42667276, ..., 0.5527275 , 0.5470512 ,
0.5260853 ]], dtype=float32)
>>> img_oct = img_float.convert('L')
>>> numpy.array(img_oct)
array([[0, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0],
...,
[0, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0]], dtype=uint8)
>>>
The input image is a 16 bit PNG made with GIMP, as attached below.
terrain_input.png
What versions of Pillow and Python are you using?
Using Python 3.6.5 and Pillow 5.1.0
- Langage dominant
- Python
- Étoiles
- 14k
- Forks
- 2.6k
- Merge moyen
- 1 j 1 h
- PR mergées (30 j)
- 205
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de python-pillow/Pillow
-
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
python-pillow/Pillow#10590 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
python-pillow/Pillow#10589 ·
Les mainteneurs répondent en général sous 1 jour
-
Sun raster files with RLE encoding and odd-width rows decode shiftedPeut-être pris @PerryLink l’a pris il y a 21 jours. Ouverte🤖-assisted
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
python-pillow/Pillow#10370 · 3 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
Warn that pre-applying arabic_reshaper + python-bidi corrupts text on a Raqm buildPeut-être pris @Syamjith-NK l’a pris il y a 85 jours. OuverteDocumentation Font Rendering PNG Third Party Framework
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
python-pillow/Pillow#9907 · 3 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
Example code in ImageText documentation makes incorrect use of get_bbox()Peut-être pris @mmporong l’a pris aujourd’hui. OuverteDocumentation
Difficulté 1/5 Moins d'une heure Accessibilité débutants 25/100
python-pillow/Pillow#10583 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de python-pillow/Pillow
Issues similaires
-
[Bug]: DoubleMLData.from_arrays checks the treatment d with force_all_x_finite instead of force_all_d_finitePeut-être pris @leninworld l’a pris aujourd’hui. Ouverte
Difficulté 1/5 Moins d'une heure Accessibilité débutants 88/100
DoubleML/doubleml-for-py#471 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 85/100
-
Difficulté 2/5 1-3 heures Accessibilité débutants 62/100
Les mainteneurs répondent en général sous 1 jour
-
BUG: ZarrTrace fails in init_trace for models with datetime coordinates (object dtype coord array)Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 74/100
Les mainteneurs répondent en général sous 2 jours
-
[Bug] Default key routing (JavaStringHash) picks a different partition than the Java client for about half of keysPeut-être pris @0z5a l’a pris aujourd’hui. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
apache/pulsar-client-go#1575 ·
Les mainteneurs répondent en général sous 2 jours