| Reference | Downloads | Github

Display a colored image with pixels stored as numpy array



I would like to display a colored disc, with every pixel’s RGB values specified in a numpy array. I can generate the image as a 3D numpy array (n rows of pixel x n columns of pixels x 3 colors RGB), but I can’t find a way to display it.

The closest thread I could find is the following, but it’s not exactly what I’d like to have in my stimulus.

May I ask if ImageStim or GratingStim can do this? If so , how do I pass the pixel array to the object?



You can pass the array as the image argument to ImageStim or the tex argument to GratingStim.


Thanks! It works now with ImageStim. I was stuck before as I didn’t know the size argument is necessary for ImageStim.