Rounding of small values of contrast

Given my 8 bits of color depth, I guess that the minimal contrast that I can display is 1/2^8, which is about 0.004, but I realized that when I set up the contrast to a value much smaller than that (e.g. .0000001), I still can see the stimulus, which means that something is presented. Shouldn’t such a small value be rounded to zero and nothing being presented?

Below some code in which I can see the stimulus despite the small contrast:

from psychopy import core, visual, event
win = visual.Window([400, 400.0], allowGUI=False)

gabor = visual.GratingStim(win,size=1.0, sf=8)
trialClock = core.Clock()

while trialClock.getTime() < 20: 
    gabor.contrast=.0000001
    gabor.phase += 0.01
    gabor.draw()
    # handle key presses each frame
    if event.getKeys(keyList=['escape', 'q']):
        win.close()
        core.quit()

    win.flip()

win.close()
core.quit()

Hi Dani. It might be that the representation of 0 (in [-1 to +1] range) maps on to something like 127.5 before 8-bit conversion. If so, any nonzero contrast would push it into rounding to 127 or 128 depending on the phase of the grating (if it is using a nearest-rounding method).

1 Like

I’ve run into this before and used the setOpacity command as workaround.

1 Like