Blend function - please help (MATLAB 2020b)
7 ビュー (過去 30 日間)
古いコメントを表示
Hi,
Could someone clarify to me what the function below is needed for when setting up a script to run a stroop task?
Screen('BlendFunction', window, 'GL_SRC_ALPHA', 'GL_ONE_MINUS_SRC_ALPHA');
Many thanks in advance.
0 件のコメント
回答 (1 件)
Walter Roberson
2020 年 10 月 29 日
"The most common alpha-blending factors are sourceFactorNew = GL_SRC_ALPHA and destinationFactorNew = GL_ONE_MINUS_SRC_ALPHA They are needed for proper anti-aliasing (smoothing) by Screen(‘DrawLines’), Screen(‘DrawDots’) and for drawing masked stimuli with the Screen(‘DrawTexture’) command."
Screen('BlendFunction', window, 'GL_SRC_ALPHA', 'GL_ONE_MINUS_SRC_ALPHA');
is telling Psychtoolbox to use compute:
information to store = new screen data * alpha + old screen data * (1-alpha)
so for example if alpha were .8 then it would be new*0.8 + old*0.2
2 件のコメント
Thomas Pace
2021 年 2 月 16 日
So if, for example, I wanted to present 4 textures using Screen('DrawTexture') in the same location, and have them all end up with equal alpha, what is the formula I would use for dictating each textures globalAlpha values?
For example, if globalAlpha (GA) for the first texture drawn was set at 1, I assumed the second texture drawn on top would need to be presented with GA of 0.5. But then what would the third texture drawn GA be such that all 3 have equally presented energy? Is there a formula for this?
Walter Roberson
2021 年 2 月 16 日
編集済み: Walter Roberson
2021 年 2 月 16 日
syms I1 I2 I3 I4 a1 a2 a3
t1 = I1*(1-a1) + I2*a1
t2 = t1*(1-a2) + I3*a2
t3 = t2*(1-a3) + I4*a3
t4 = collect(expand(t3),[I1,I2,I3,I4])
c1 = coeffs(t4,I1)
c2 = coeffs(t4,I2)
c3 = coeffs(t4,I3)
c4 = coeffs(t4,I4)
sol = solve([c1(end),c2(end),c3(end)]==1/4,[a1,a2,a3])
sol.a1
sol.a2
sol.a3
%cross-check
subs([c1(end),c2(end),c3(end),c4(end)], sol)
So use alpha = 1/2 for the first overlay, alpha = 1/3 for the second overlay, alpha = 1/4 for the third overlay.
参考
カテゴリ
Help Center および File Exchange で Image display and manipulation についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!