Grayscale images (as numpy arrays) display as blue for values of exactly -1?

I am using a grayscale image as a numpy array as the “image” keyword argument for the ImageStim constructor. I use PIL to read the images and convert them to grayscale (0 - 255), but I keep getting a warning that says: “WARNING : numpy arrays used as textures must be in the range of -1:1” or something along these lines, and the images are just totally mangled on the display (they appear mostly red with some black). I tried re-scaling the images using sci-kit learn’s exposure module (see the code below), and I verified that the minimum and maximum values in these arrays are -1 and +1 respectively; however, I still get this warning, and pixels with an intensity of exactly -1 are displayed as blue. Can someone explain this behavior to me and help me find a solution? Here is a minimal example of how I process the images and create the stimulus:

import numpy as np
from PIL import Image
from skimage import exposure
from psychopy import visual

tif = <some image file>
image = np.array(Image.open(tif).convert('L')) # only 2 dimensions
image_rescaled = exposure.rescale_intensity(image, in_range=(0, 255), out_range=(-1, 1))
win = visual.Window()
stim = visual.ImageStim(win, image=image_rescaled)

I’m using psychopy version 2020.1.2

If you’re starting with a greyscale image, does that mean it has channels for red, green and blue but these are fixed to equal one another, or that it only has one channel? This sounds like what I’d expect from an image where only the red channel is set and the others are fixed to -1, you may need to duplicate your array along a third dimension so that you have RGB values rather than just R.

Hello, I just meet some troubles in import skimage. Could you share the way to install it and import it? Thanks a lot!