File: showImages.rst

package info (click to toggle)
psychopy 2023.2.4%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 124,456 kB
  • sloc: python: 126,213; javascript: 11,982; makefile: 152; sh: 120; xml: 9
file content (12 lines) | stat: -rw-r--r-- 861 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
.. _showImages:

Coder - show images
================================

Sometimes we want to use PsychoPy to show images --- either read from an image file (such as `.png`) or from a Numpy array. We can use either the :class:`psychopy.visual.ImageStim` or :class:`psychopy.visual.GratingStim` to achieve this. However, some of the nuances of actually getting the correct image to screen can be difficult to figure out.

This recipe demonstrates (1) a way to use :class:`psychopy.visual.ImageStim` to read an image from disc and show it, and (2) using :class:`psychopy.visual.ImageStim` to show a numpy array as an image.

When showing and converting images, you need to be careful about data types and channels. The `scikit-image docs on this <https://scikit-image.org/docs/stable/user_guide/data_types.html>`_ are quite good.

.. literalinclude:: showImages.py