Log in

View Full Version : Photoshop like RGB levels


kingmob
13th July 2004, 14:13
Is adjusting levels in RGB in any way available in avisynth? I have some underwater video's which need some heavy level adjusting. But if i use normal B&W levels, the blue underwater color stays even though the quality gets better. As you may know Red is heavily filtered in water. Thus all the red information is for example around 100, while Green is around 180 and blue is around 200.
Using adobe premiere or photoshop on stills i can adjust these levels seperately thus removing the blue 'feel'. Therefore i know what values i need, al i need to do is fill them in now.

I also tried colorYUV with autowhite=yes, but this removed too many blue (i still want it to be a little blue) and created some grey areas.

So does this filter exist? I couldn't find any with the search option. What i've done now is encode it in premiere as HuffYuv, which is ok i guess, but it would be nice if i could just add it in an avs script.

scharfis_brain
13th July 2004, 14:31
try using manaos mastools.dll

there is included a function called RGBLut.

it is able importing photoshops curves - files

kingmob
13th July 2004, 14:46
I'm guessing you mean masktools.dll. However, i can't find anything relating to the function RGBlut. Could you elaborate a bit maybe?

Manao
13th July 2004, 18:19
Have a look at this post (http://forum.doom9.org/showthread.php?s=&postid=475634&highlight=rgblut#post475634)

I never documented the filter, because the Masktools is a set of YV12 filters, and this one is RGB.

You can download it here (http://jourdan.madism.org/~manao/)

malkion
13th July 2004, 18:29
@Manao,

Could you release a new masktools to support the new float divisor in the latest AviSynth beta?

Manao
13th July 2004, 18:43
Uh ? AFAIK, it's already 'supported', though not in the same way. This is taken from the documentation :If one of the coefficients of horizontal or vertical is a real number, all the computations will be made with floats, so the filter will be slower

malkion
13th July 2004, 23:43
@Manao, I was hoping to get it here...

DEdgeMask(clip, int thY1, int thY2, int thC1, int thC2, string matrix, int divisor)

Could that last divisor take a float?

Manao
14th July 2004, 03:21
I had forgotten that DEdgeMask was also doing a convolution :)

I'll see what I can do, expect something before the end of the week.

kingmob
14th July 2004, 12:07
Hey, thx for the help. This should work :).

kingmob
14th July 2004, 13:34
I'm using RGBlut atm, but somethings wrong and i can't figure out why.
I use the following statement to translate the levels information of photoshop in the function:

Levels(il,gamma,ih,ol,oh): "x il - ih il - / gamma ^ oh ol - *".

So now my avs file looks like this:


AVISource("Nemo2.avi")
#ConvertToYUY2()
#levels(100,1.065,225,0,255)
RGBLUT(Rexpr="x 25 - 110 25 - / 0.80 ^ 255 *", Gexpr="x 140 - 215 140 - / 1.20 ^ 255 *",\
Bexpr="x 135 - 230 135 - / 1.45 ^ 255 *")

But this does not show the same effect as in premiere. Strangely enough, when i change the gamma paramater, it works the opposite way it should work. Thus lowering the red gamma actually makes my image redder?
Can anyone point out my mistake?

Manao
14th July 2004, 13:47
It's my fault, it seems I gave the wrong formula for Levels."x il - ih il - / gamma ^ oh ol - *" has to become :

"x il - ih il - / 1 gamma / ^ oh ol - *"

I forgot to invert gamma. I'll correct the documentation ASAP. Thanks for pointing that fact to me.

kingmob
14th July 2004, 14:10
Ah, i tought about trying that after i posted it (would seem logical if somethings working exactly the other way around :rolleyes: ). Thanks for the help, looks like it works now.

Hmm, seems it doesn't. Look at the difference, both with exact the same values as far as i know:

http://hal9000.fttd-s.tudelft.nl/sjoerd/levels.jpg

Some extra info:
I've just tried inputting a *.lvl file from premiere. I get returned a video, but it's unaltered. As a matter of fact, the avs image in my image above, is the unaltered video, so for some reason RGBlut isn't doing anything, but not giving an error either...

Didée
14th July 2004, 14:21
Manao:

I'm occupying YV12lut for levels operations for quite some time now ;) - And the TXT documentation ever was correct, AFAIK.

But I have to points:

1.
All levels operations through LUT behave different to Avisynth's levels in one regard: they do no clipping.

E.g. levels( 32, 1.0, 240, 40, 208) will clamp all IN values <32 to OUT=40, and IN>240 to OUT=208.
Doing the same through LUT, there is no clipping: values <32 will be mapped to <40, and >240 to >208, accordingly.

This is not a bug, but a very nice feature! Just thought this difference should be pointed out.


2.
But something other seems to NOT work correctly:

When trying to adjust gamma/levels differently for both <(threshold) and >(threshold) by means of "?" conditional operator, then the results are not reliable.

Don't have my scripts at hand now, sorry ... but try for yourself:

if one does sth like Yexpr="x 128 < [expression1] [expression2] ?"

where expression1|2 are manipulating BOTH in/output/lo/hi AND gamma, then the result is ... interesting, but not correct - hence unusable.

Something seems buried deep within ... for normal, full-range operations without this "thresholded splitting", it's always working correctly.


BTW - was there ever a (Avisynth) life before MaskTools? :D


- Didée

Manao
14th July 2004, 14:26
By default, RGBLUT works only the red channel by default. I know it's kind of dumb, but I made that filter really quickly ( meaning a lot of copy & paste ), and for YUV, it was making some sense just to treat the luma channel by default.

So, you should try to add R = 3, G = 3, B = 3 in the filter's parameters.

kingmob
14th July 2004, 14:38
Thanks, that did it :).

I'd like to point out that i can only find two types of photoshop files relating to levels btw (both in photoshop and premiere). That is the *lvl for levels and *acv for curves. And it did an odd job of using it.

But since it now works i don't care that much ;).

Manao
14th July 2004, 14:42
Just thought this difference should be pointed out.Indeed. I'll add it to the documentation.But something other seems to NOT work correctlyI'll wait for you to find your scripts, because it always worked for me. The reverse polonese notation can be quite tricky sometimes.

kingmob : OK, glad to hear it work. I'll document that filter, it will avoid further complication.