[Pixel Bender] Bright Pass filter

I’m pretty sure you already heard about pixel bender, if not check Adobe’s  or Lee Brimelow’s website for awsome tutorials. 

Today I gonna share with you, my first pixel bender code ever, which is a bright pass filter. This filter set the dark pixels to black according a threshold value for the ‘darkness’.

kernel BrightPassFilter
< namespace : "com.gun.uieffect.filter"; vendor : "Guillaume Nachury. https://proofofconcepts.wordpress.com/"; version : 1; description : "Set all the dark pixels to black. The dark threshold value can be modified."; >
input image4 src;
output pixel4 dst;

parameter float thresholdValue;

float Mx;
float mn;
float l;

pixel4 p;
p = sampleNearest(src,outCoord());

Here are some formulas to get the lightness :

/*(1) This one gave the best results so far.*/
l = (240.0/255.0)*(0.239*p.r+0.686*p.g+0.075*p.b);

/*(2) Quite the same as above but a bit tweaked
l = (240.0/255.0)*(0.300*p.r+0.590*p.g+0.110*p.b);

/*(3) This one requires some steps before getting the lightness
//Find which component is the highest
if((p.r > p.g) && (p.r > p.b)){
Mx = p.r;
else if((p.g > p.r) && (p.g > p.b)){
Mx = p.g;
else if((p.b > p.g) && (p.b > p.r)){
Mx = p.b;

//Find which component is the lowest
if((p.r < p.g) && (p.r < p.b)){ mn = p.r; } else if((p.g < p.r) && (p.g < p.b)){ mn = p.g; } else if((p.b < p.g) && (p.b < p.r)){ mn = p.b; } l = 0.5*240.0*( (Mx+mn)/255.0), */ /*Formula I found, but not sure of the result l = (240.0/255.0)*Mx; */ if(l


Back online

The last 2 months were just restless for me, except my 3 weeks off where I had the chance to go 1 week in the French Alps, 1 week at the sea and 1 week in Croatia.(This country is beautiful by the way), my ‘main tasks’ list was HUGE.

Tasks List :

  • Finish my professionnal dev. done
  • Writing docs. On progress  (I really hate this part…)
  • Fixing my car. done
  • Posting some CoolUselessHack here. On progress (I have a lot of ideas)
  • Getting back to university every night in order to finish my MSc in Computer science. On progress -_-zzZZz
  • Finding a new job. On progress
  • Playing Warhammer Online. << grr.. not enough hours in a day (damn small 24h)
  • Writing LUA addons for warhammer Online. done (OMG I realize that I spend more time coding addons than playing…)
  • Playing with pixel bender. On progress
  • Buying Sheldon’s green lantern tshirt. You can buy me one here 😉 
  • …and alot more