Skip to content

Feature request: skimage.io.imdecode #2889

Closed

Description

@dwSun

Description

We have to write the image to disk for skimage to read from it.
Why not let skimage.io to decode form a bytes string directly inside memory.

Activity

  1. soupault commented on Nov 22, 2017

    @soupault
    Member

    @dwSun this would be a useful feature, I agree. One of the usecases is to decode a received via REST, gRPC bytesting.
    Even if we decide not to incorporate such function, you can always use imread with imageio plugin which supports reading from bytes (see http://imageio.readthedocs.io/en/latest/userapi.html#imageio.imread):

    import os
    import skimage
    from skimage import io
    
    p = skimage.data_dir
    with open(os.path.join(p, 'coins.png'), 'rb') as f:
        b = f.read()
    
    img = imread(b, plugin='imageio')
    
    img
    
    Image([[ 47, 123, 133, ...,  14,   3,  12],
           [ 93, 144, 145, ...,  12,   7,   7],
           [126, 147, 143, ...,   2,  13,   3],
           ..., 
           [ 81,  79,  74, ...,   6,   4,   7],
           [ 88,  82,  74, ...,   5,   7,   8],
           [ 91,  79,  68, ...,   4,  10,   7]], dtype=uint8)
    
  2. added this to the 0.14 milestone on Nov 22, 2017
  3. dwSun commented on Nov 22, 2017

    @dwSun
    Author

    @soupault thanks for your reply and your solution. I will use imageio plugin to decode my image bytestring.

  4. emmanuelle commented on Nov 22, 2017

    @emmanuelle
    Member

    The solution by @soupault looks simple and straightforward. Do we need a specific function for that? Or should the example appear in the doc? It's my usual reaction to try to keep the API as short as possible :-).

  5. soupault commented on Nov 22, 2017

    @soupault
    Member

    @emmanuelle mentioning this case in the docstring will do it for me. :)

  6. stefanv commented on Nov 22, 2017

    @stefanv
    Member

    Also, imread can detect when the object is a bytestream and automatically attempt to use imageio? Also, we should just switch to imageio by default.

  7. added
    🔰 Good first issue
    ⏩ type: Enhancement
    and removed on Nov 29, 2017
  8. modified the milestones: 0.14, 0.14.1 on Feb 13, 2018
  9. jni commented on Feb 13, 2018

    @jni
    Member

    I've changed the milestone, because I don't think this should hold up 0.14

  10. modified the milestones: 0.14.1, 0.15 on Apr 27, 2018
  11. added 3 commits that reference this issue on May 30, 2018
    4cce98a
    75ec603
    37a0e20
  12. added a commit that references this issue on Jun 30, 2018
    35535df
  13. added a commit that references this issue on Jul 26, 2018
    a5818a6
  14. added a commit that references this issue on Jul 28, 2018
    261e722
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

    🔰 Good first issue⏩ type: Enhancement

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions