Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

stimuli.Picture data sources

edited March 15 in Expyriment

Hi all,

The documentation for the stimuli.Picture class shows how to create a Picture stimulus from an image file given a file path, but is there any way to create a Picture stimulus from a python data structure, e.g., an Image object as returned by the Pillow library? I'm thinking about use cases where a user might want to read in an image file, and transform it in some way (convert to greyscale, resize) before presenting it.

Thanks for any guidance!

Comments

  • edited April 4

    Hi,

    not directly in Expyriment. But you could probably attempt to manipulate the surface of the stimulus (which is a Pygame surface). I would, however, suggest to not do this, as it might break some Expyriment internal things for that stimulus.

    As an alternative, I would probably just first open the picture with Pillow, manipulate it there, save it as a temporary file, and load that file as an Expyriment Picture stimulus.

    Best,
    Florian

    Florian Krause (Developer)
    http://www.expyriment.org

  • Dear Whopper,

    if you need Pillow images you can use the following new Expyriment (extra) stimulus class, which will be soon available via the experiment-stash. https://gist.github.com/lindemann09/3d9f114081618dfba99a3ebfa9a7663b

    greetings,
    Oliver

Sign In or Register to comment.