Tag Archives: photoshop

Pixel Bender : ft-Auto White Balance for After Effects & Photoshop

Introduction

This filter which works for After Effects & Photoshop, will color balance your footage based in case the white balance wasn’t set properly at the time you were shooting it.

All you have to do is select a mid-tone color in your footage and the filter will do the rest.

Download

Pixel Bender shader : ft-Auto White Balance

How to install it ?

Just copy the .pbk file into your “Support Files” folder in your AE install directory

Donate

Faster Array Sort in Javascript

Introduction :

Based on Eugene(inspirit) post about Faster Array Sort function in Flash, I ported his test code into javascript.
First of all, I’m mainly using JS for scripting into Adobe After Effects, Photoshop, … but not so much for web anyway. That being said I’m not a javascript guru, so bare with me if I did mistake, I took his code and just changed it a little bit so it would work in JS.

I still can’t make the “Flash Sort” (which seems to be the fastest one on AS) to work w/ JS. I don’t know what I’m doing wrong, if anyone has an idea ?

[UPDATE] Thx to MrDoob, “Flash Sort” works now !! I also add the check function and it seems some sorting still not working quite well.


Download Source Code :



Stats


Firefox

*******************************************
*******************************************
INFO
10 000 elements
User-agent header: Mozilla/5.0 (Windows; U; Windows NT 6.0; fr; rv:1.9.2.10) Gecko/20100914 Firefox/3.6.10 ( .NET CLR 3.5.30729; .NET4.0E)
——————————————————————–

JS BUILD IN SORT
Time : 18 ms
Sorting is OK
——————————————————————–

QUICK SORT + INSERTION SORT
Time : 9 ms
Sorting is wrong
——————————————————————–

3 WAY QUICK SORT
Time : 11 ms
Sorting is wrong
——————————————————————–

NON RECURSIVE QUICK SORT
Time : 15 ms
Sorting is OK
——————————————————————–

OPTIMIZED NON RECURSIVE QUICK SORT
Time : 16 ms
Sorting is OK
——————————————————————–

NON RECURSIVE QUICK SORT 2
Time : 13 ms
Sorting is OK
——————————————————————–

FLASH SORT
Time : 6 ms
Sorting is OK
——————————————————————–

IE 8

*******************************************
*******************************************
INFO
10 000 elements
User-agent header: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; SLCC1; .NET CLR 2.0.50727; Tablet PC 2.0; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET4.0C; .NET4.0E)
——————————————————————–

JS BUILD IN SORT
Time : 88 ms
Sorting is OK
——————————————————————–

QUICK SORT + INSERTION SORT
Time : 34 ms
Sorting is wrong
——————————————————————–

3 WAY QUICK SORT
Time : 47 ms
Sorting is wrong
——————————————————————–

NON RECURSIVE QUICK SORT
Time : 49 ms
Sorting is OK
——————————————————————–

OPTIMIZED NON RECURSIVE QUICK SORT
Time : 42 ms
Sorting is OK
——————————————————————–

NON RECURSIVE QUICK SORT 2
Time : 49 ms
Sorting is OK
——————————————————————–

FLASH SORT
Time : 30 ms
Sorting is OK
——————————————————————–

Chrome

*******************************************
*******************************************
INFO
10 000 elements
User-agent header: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/534.3 (KHTML, like Gecko) Chrome/6.0.472.63 Safari/534.3
——————————————————————–

JS BUILD IN SORT
Time : 13 ms
Sorting is OK
——————————————————————–

QUICK SORT + INSERTION SORT
Time : 4 ms
Sorting is wrong
——————————————————————–

3 WAY QUICK SORT
Time : 3 ms
Sorting is wrong
——————————————————————–

NON RECURSIVE QUICK SORT
Time : 3 ms
Sorting is OK
——————————————————————–

OPTIMIZED NON RECURSIVE QUICK SORT
Time : 3 ms
Sorting is OK
——————————————————————–

NON RECURSIVE QUICK SORT 2
Time : 3 ms
Sorting is OK
——————————————————————–

FLASH SORT
Time : 3 ms
Sorting is OK
——————————————————————–

Adobe After Effects

*******************************************
*******************************************
INFO
10 000 elements
OS : Windows Vista 6.0 Service Pack 2
——————————————————————–
JS BUILD IN SORT
Time : 291 ms
Sorting is OK
——————————————————————–
QUICK SORT + INSERTION SORT
Time : 237 ms
Sorting is wrong
——————————————————————–
3 WAY QUICK SORT
Time : 251 ms
Sorting is wrong
——————————————————————–
NON RECURSIVE QUICK SORT
Time : 287 ms
Sorting is wrong
——————————————————————–
OPTIMIZED NON RECURSIVE QUICK SORT
Time : 250 ms
Sorting is wrong
——————————————————————–
NON RECURSIVE QUICK SORT 2
Time : 298 ms
Sorting is OK
——————————————————————–
FLASH SORT
Time : 281 ms
Sorting is wrong
——————————————————————–

Saturation Shader

saturation-panel

This one should be pretty simple, but still all the shaders I have found on the Internet was based on conversion to HSL color space. Which could be actually useful if  you need some color balance control, but if you just want to control the saturation as fast as you can, it’s probably not the right approach.

Anyway here is a small shader which does the trick (Media Player Classic) :

http://www.pasteall.org/8891/c

Exposure/Offset/Gamma photoshop tool to Shaders

The goal here was to understand how works the Exposure feature of Photoshop for my research on lift/gamma/gain

exposure-photoshop-panel

NB : I wouldn’t say I’m an 100% sure about how it works, but that’s how I understood it worked so far


Exposure :

I though exposure was more complicated than that (maybe it is) but the way I’m reproducing it, is only by adding a percentage of the pixel by himself. nothing more complicated than that.


Offset :

As seen in my previous post, the Offset is just an Add of a value. My first approach on it was saying Offset is controlling the luminance of it, so I guess the correct way would be to convert the pixel in the YCbCr color space, add a value to the Y channel, and reconverting back to RBG color space. But this is doing a lot of calculation for nothing, while adding just a value to the entire picture would probably do the same, and actually would correspond to the Lift (or Offset of the CDL).
Plus switching between color space makes you loose some tiny precision in the color.

Anyway, I’ll give the two solutions, please let me know if you think one is better than the other


Gamma :


As usual, power(1/gamma)

The right order :

If all this was actually all pretty simple, at least I learned one thing (obvious as well I must say). Don’t forget to do the operation in the right order. In my first try I had a small bug, and couldn’t have the same result in Photoshop & in my shader, because I was doing the offset before the exposure. Which is pretty silly, since if you do that, you are loosing all the dynamic range of your picture when you actually want to have as much information as you can for your exposure.

The order is Exposure -> Offset -> Gamma.


Formula :

output = ((input*exposure) + offset)^(1/gamma)

hum… looks a lot like the CDL formula doesn’t it ? 🙂 Except exposure is a single float value between 0 and 20 ? (maybe more, maybe less depends of your picture)and the default value should be 1.The offset should be between -10 ? and 1 I think.


Shaders (HLSL in Media Player Classic) :

http://www.pasteall.org/8868/c

Here I’m giving the version with YCbCr conversion, but I’m pretty sure it is not doing anything more than the above one, except loosing information in conversion. But at least it shows the YCbCr conversion 🙂

http://www.pasteall.org/8869/c