blue filter
Hi,
I'm trying to show grayscale pictures in blue in an inline_script.
I want to do this by drawing a transparent blue picture on top of it (because I have about 4200 pictures to colorize myself otherwise).
The pseudo-code would than be something like this:
exp.canvas = self.offline_canvas()
exp.canvas.image(picture, x, y, etc)
exp.canvas.rect(x, y, w, h, color=blue, fill=True, alpha=0.5)
I've already tried it with GratingStim from psychopy.visual, but that opened a new screen next to the screen that the picture was shown on)
Does anyone know a solution that'll help?
Comments
Hi,
A semitransparent overlay changes the colors, but differently from a color-swap—which is presumably what you're after, right? For example, a blue overlay would make a black background blueish.
Below is a simple script that reads an image file, and then mutes one or more of the color channels. So it does proper recoloring.
Do you see the logic? A bitmap is just an array, and the third dimension has the color channels [red, green, blue]. And you can mute a color channel (i.e. remove a color) by setting it to 0.
Now say that you have an image file in the file pool called
original.png. Then the following would create a filtered image file in the file pool calledblue.png:You can just do this on every trial, and the use the filtered image in a
sketchpad,canvas, or what have you.Cheers!
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!