Skip to content

Horizontally flip not correctly handling uint16 data #3500

Description

@rainbean

What did you do?

create an uint16 img and invoke img.transpose(Image.FLIP_LEFT_RIGHT)

What did you expect to happen?

horizontally flip the given PIL Image

What actually happened?

random data overflow

What are your OS, Python and Pillow versions?

  • OS: Ubuntu & macOS
  • Python: 3.6
  • Pillow: 5.1.0 ~ 5.3.0 tested
import numpy as np
from PIL import Image
x = np.zeros((10, 10), dtype=np.uint16)
x[1:4, 2:5] = 1
x[5:8, 5:8] = 2
y = Image.fromarray(x)
assert 2 == np.max(y)
y_ = y.transpose(Image.FLIP_LEFT_RIGHT)
assert 2 == np.max(y_) # error occurred, FLIP_TOP_BOTTOM is okay

Activity

  1. changed the title [-]Horizontally flip not correctly handle uint16 data[/-] [+]Horizontally flip not correctly handling uint16 data[/+] on Dec 18, 2018
  2. surgan12 commented on Dec 20, 2018

    @surgan12

    Also uint16 numpy array not converting to Image

  3. radarhere commented on Jan 9, 2019

    @radarhere
    Member

    @surgan12 could you elaborate on what you mean? Are you able to provide a code example? I would have thought that the earlier code is doing exactly that - converting a uint16 numpy array to an image.

  4. radarhere commented on Jan 9, 2019

    @radarhere
    Member

    I've created PR #3563 to try and resolve this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions