2012-03-22 32 views
1

我是基於Adobe公司的文檔從頭開始研發的柔光算法: http://www.adobe.com/content/dam/Adobe/en/devnet/pdf/pdfs/pdf_reference_archives/blend_modes.pdf http://opensource.adobe.com/svn/opensource/flex /sdk/trunk/frameworks/projects/framework/src/mx/graphics/shaderClasses/SoftLight.pbk圖像處理:像Photoshop一樣的柔光算法

能爲我誰能解釋的算法或至少dst, src, cb, cssampleNearest()功能以及如何計算呢? 謝謝!

input image4 dst; 
input image4 src; 
output pixel4 result; 

void 
evaluatePixel() 
{ 
    pixel4 a = sampleNearest(dst,outCoord()); // cb 
    pixel4 b = sampleNearest(src,outCoord()); // cs 
    .... 
} 

回答

1

See this answer爲混合式:

 ChannelBlend_SoftLight(A,B) ((uint8)((B < 128)?(2*((A>>1)+64))*((float)B/255):(255-(2*(255-((A>>1)+64))*(float)(255-B)/255)))) 

您的代碼以上計算一個像素的混合。

a, b是2個不同的像素,aampleNearest函數從輸入圖像中獲取2個像素。

dst,src是2個輸入圖像。

+0

我試圖將一朵花和一張白色圖像的圖像混合爲SoftLight,然後得到一張白色圖像作爲結果。在GIMP或者photoshop中,它工作正常...我做錯了什麼? – 2015-04-22 15:20:11