PDA

View Full Version : Pixel value clipping?


fjhdavid
22nd April 2009, 19:56
I have an YV12 clip with values going from 32 to 235. so when I watch the clip, "black part of the clip" look a little bit grey (value=32 instead of 16).

I would like like to get real black, so I just want to apply the following filter:

for all pixel values >32, new pixel value will stay as they are
for all pixel values <32, new pixel value will be set to 16

Is it possible?

Thanks

Francois

Manao
22nd April 2009, 20:12
mt_masktools : mt_lut("x 32 < 16 x ?", chroma="copy")

fjhdavid
22nd April 2009, 20:24
Thank you!

I just downloaded the Masktools and I look into your documentation.

chroma="copy" means this parameter leave the chroma as it is?

Francois

Manao
22nd April 2009, 20:32
Yes (it's documented under "common parameters")

fjhdavid
8th June 2009, 00:39
Manao,

After looking with photoshop, there is a problem with my script (trying to use your suggestion).
My script is:

x=last
y=mt_lut("x 32 < 16 x ?", chroma="copy")
mergeluma(y)

and "black pixel" are still grey.

Where did I made a mistake in my script?

thanks
Francois

PS: of course I want to apply this filter only on Y (and not on U and V)

thetoof
8th June 2009, 01:05
Not exactly an answer to your question, but I'd recommend smoothlevels if you want to go full PC range (looks better imo than simply replacing values to get "real greys").

fjhdavid
8th June 2009, 16:36
sorry for my thread and my question, I found the solution...

The script was ok but my "bad pixels" were just Y=34...then the limit of 32 was not sufficient.

Manao, thanks for this function mt_lut !

Francois

Manao
8th June 2009, 18:15
x=last
y=mt_lut("x 32 < 16 x ?", chroma="copy")
mergeluma(y)Just do :mt_lut("x 32 < 16 x ?", chroma="copy")

IanB
9th June 2009, 00:22
@fjhdavid,

Look into Histogram(), ColorYUV(Analyze=True) or RGBAdjust(Analyze=True) to see the luma distribution of your source.

You probable want to stretch the luma range rather than just declare a hard limit. Something like a simple :-Levels(16, 1.0, 255, 0, 255, False)or one of the many related methods.