Why does interpolation=True affect values (decimal or integer) set to the lineWidth

I can see an increase in the width of a line as I assign the lineWidth to decimal values like 0.5, 0.6, 0.7, 0.8, 1, 1.2, 1.5 …etc. when the interpolation=True. But when the interpolation=False, the width of the line can only be increased if I set integers (1,2,3,…etc) to the lineWidth.

I know that ‘lineWidth’ specifies the line width in pixels. So, I am having trouble understanding how the lineWidth can be assigned to decimals when interpolation is set to ‘True’, but not when interpolation is set to ‘False’.

Also, with the same reasoning, I can set the position of the line to decimals when the interpolation=True, but not when interpolation=False.

Is interpolation=True a reliable option to gradually increase the width, or should I use interpolate=False while testing different line widths?

Thanks,
Zeynep

Pixels are inherently discrete objects. They are either on or off. So let’s say you are drawing white lines on a black background. The lines can only ever be discrete values of 1, 2, 3, … pixels wide.

Now let’s say you enable interpolation. Pixels can still only be on or off, but this relaxes the restriction on what colours they can be. Pixels along the line can now take on shades of grey rather than just be black or white. This is just a perceptual trick that makes it appear as if lines are smoother than the size of the underlying pixels would otherwise allow for, and also makes it possible for lines to appear to have thicknesses that fall in between the integer values:

1 Like

Thanks for your response @Michael. I now understand the difference between two. Then, how do I know about the exact size I test (in terms of degrees) when I set interpolation=True?
For example, 1 pixel corresponds to 0.035 deg in my current display settings (I calculate it with pix2deg function). How do I convert 0.5 pixel to degrees when I use interpolate=True? Can I use the same exact function?

You’re seeking a degree of perfection that isn’t really obtainable. When working with interpolated lines, the “actual” thickness depends on a lot of assumptions. The line can’t ever truly be less than one pixel thick, although it might appear thinner than a one-pixel line depending on the anti-aliasing algorithm used. As pixels aren’t simply on or off anymore, that requires setting some sort of threshold for the line boundary, and that value will change from point to point along any line that isn’t perfectly vertical or horizontal. And the values will depend on the actual implementation of the anti-aliasing, which will vary not only with line orientation, but potentially with many combinations of operating system, graphics card, and display hardware. PsychoPy can’t really tell you that: it just constructs the lines in terms of coordinates and sends them off to be drawn. It won’t necessarily know the details of the anti-aliasing method used at the pixel level.

If this stuff is really a concern, I’d suggest that you get a “retina” scale resolution display where the pixels are so tiny it doesn’t really matter anymore.

1 Like