Calculating contrast

Use this forum to ask questions about how to do things or how to fix problems in PSYKINEMATIX 1.0

Calculating contrast

Postby eddahaggerty » Wed Oct 21, 2020 4:19 pm

Hello,

I am creating a black and white custom visual stimulus. I would assume that contrast = 1 would be white and contrast = 0 would be black in all cases. This is generally so, but I'm having trouble with the following stimuli code:

env=r<radius_g # outer ring
env = ((contrast_c + contrast_g)/2)*env # set contrast for outer ring
center = contrast_c*(r<radius_c) # center
z = env + center

Setting contrast_c to 0.75 is the brightest that the inner circle will go, while setting it to 0.76 makes it black but setting it lower than 0.75 also makes it get continually dimmer. Could someone explain to me how contrast is being calculated here? (My background is set to 50% contrast throughout the experiment if that is relevant in any way.)

Thank you!
eddahaggerty
 
Posts: 4
Joined: Thu Oct 08, 2020 12:52 pm

Re: Calculating contrast

Postby psykinematix » Thu Oct 22, 2020 6:34 am

Hi,

What you are trying to do is not clear enough: why is your goal and which rendering mode are you using (contrast- or luminance-based) ? Are you trying to set independently different contrast or luminance for the center and outer ring? Note that a contrast of 0 would not result in a black stimulus, but in a stimulus with the same luminance as the background. To obtain a pure black stimulus, you would have to set the contrast to -1. Typically the background is set as a percentage of the maximum luminance (for example 50% of maximum luminance to produce a mid-gray level), not in term of contrast. Also you have to make sure to properly create the envelope for the ring: (r>radius_c & r<radius_g), not just (r<radius_g) because this also includes the center !

Here are 2 examples to set the appearance of the center and surround:

1) In term of contrast (make sure to select the "Contrast" rendering mode below the color space with a contrast value set to 100%):

ring = contrast_g*(r>radius_c & r<radius_g)
center = contrast_c*(r<radius_c)
z = center + ring

2) In term of luminance (make sure to select the "Luminance" rendering mode below the color space with a luminance value set to 100%):

ring = 0.5*(1+contrast_g)*(r>radius_c & r<radius_g)
center = 0.5*(1+contrast_c)*(r<radius_c)
outside = 0.5*(r>radius_g)
z = center + ring + outside

Those 2 examples create the exact same stimulus. Set contrast_c to 1 to create a white center and set contrast_g to -1 to create a black ring.

Hope this helps!

The Psykinematix Support Team @ KyberVision Japan LLC
psykinematix
Site Admin
 
Posts: 59
Joined: Thu Aug 27, 2009 9:31 pm


Return to Questions, Problems and Troubleshooting

Who is online

Users browsing this forum: No registered users and 2 guests

cron