Borders on some images

Hi,

I had missed this thread when I created a similar one in 2020, bringing up the same issue Odd black/grey lines at outlines of image components

It was suggested to me, too, to simply turn off linear interpolation. This worked for the particular experiment I was working on when I created the above thread. Now, however, I need the interpolation to avoid making image components with photos look really jagged.

I did some more searching around and I found that this kind of thing can happen with interpolation in general (java - Why do I get black outlines/edges on a texture in libGDX? - Stack Overflow). Maybe the alpha channel shenanigans mentioned there are relevant to PsychoPy as well? I don’t really know enough about interpolation as it relates to color spaces to understand much of what’s going on.

In the meantime, I’m using a hack, through code snippets. First, I create a ‘no-fill’ rectangle component that has the same outline color as the background (white in my case).

rect_outlinehider = visual.Rect(
    win=win,
    name='rect_outlinehider',
    units='deg',
    width=2,
    height=2,
    ori=0,
    pos=(0, 0),
    lineWidth=0.8,
    colorSpace='rgb',
    lineColor=[1, 1, 1],
    fillColor=None,
    opacity=None,
    depth=1,
    interpolate=False
)

Then, when drawing my image components (kept in a list), for each one I assign this ‘outline hider’ component the same width/height as the image component, then draw the outline hider ‘on top of’ the image.

for img in img_ls:
    img.draw()
    rect_outlinehider.width = img.size[0]
    rect_outlinehider.height = img.size[1]
    rect_outlinehider.pos = img.pos
    rect_outlinehider.draw()

Note that this means you can’t rely on the Builder’s automatic stimulus drawing anymore. You might also want to tweak the line width of the outline hider component, to avoid having it hide important parts of the stimuli themselves.

This is an ugly hack and I’d much rather be without it, but it seems like the issue is tricky and might not be solved any time soon, so this works for me in the mean time.