Displays two gratings. The bright grating alternates white and weight*white,
producing luminances LMax and LBright.
The dim grating alternates dimWeight*white and black, producing luminances
LDim and LMin.
When the grating contrasts match, LMax/LBright=LDim/LMin.
In a more compact notation, L1/Lb=Ld/L0. We set the weight wd that produces
Ld, and the observer adjusts the weight wb that produces Lb. They are related
by the gamma function, y=g(w), where y is the normalized luminance,
y=(L-L0)/(L1-L0). We know wb and wd, and we have access to the gamma function,
so we can compute yb and yd. Solving for L, we have
Our relation at match can be rewritten as
Let’s divide by L1^2, and define r=L0/L1.
This is a quadratic equation in r
c=[(1-yd)*(1-yb) yb*(1-yd)+yd*(1-yb)-1 yd*yb]; % coefficients of quadratic polynomial
The answer, r, is the desired ratio of L0/L1.

5/28/96 dgp Wrote it.
5/28/96 dgp Updated to use new GetMouse, that flushes mouse events.
8/4/96 dhb Changed name to ContrastMatch.
8/16/97 dgp Changed “text” to “theText” to avoid conflict with TEXT function.
7/19/98 dgp Removed obsolete TIMER.
6/30/03 dgp Updated Screen OpenScreen to Screen OpenWindow.

Path   Retrieve current version from GitHub | View changelog