Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage
Register FAQ Calendar Today's Posts Search

Reply
 
Thread Tools Search this Thread Display Modes
Old 26th May 2011, 20:01   #1  |  Link
zee944
Registered User
 
Join Date: Apr 2007
Posts: 240
GiCoCu / YUV question - how to add a luma curve properly?

I'd like to add a luma curve to a video (I mean not touching the colors just making the pixels darker or brighter).

I have this little sample script:

Code:
LoadPlugin("GiCoCu.dll")

ImageReader("td_samp.png")
AddLumaCurve("full_flat.amp")	# Photoshop curve with full zeros

Function AddLumaCurve(clip src, string curve)
{# 
src
ConvertToRGB32
MergeChroma(GiCoCU(curve,photoshop=true).ConvertToYUY2,last.ConvertToYUY2)
ConvertToYV12
Return(last)
}
This is how the sample picture looks like originally:


The curve (here: full_flat.amp) I'm using here is full of zeros, meaning it should make all the 0..255 values to zeros. (Of course I will never be using a flat curve, it's just for testing.)

So theoretically the end result would be full black. It isn't:



I have ran into this before and I know it's YUV colorspace behavior and it's because U and V chroma planes are left untouched, but I just can't find the solution to elude the problem. It must be some GreyScale(), ShowRed/Green/Blue and MergeChroma/Luma trick and not even an extremely complicated one, but I'm playing around for hours now and can't figure it out. Can someone help me out? Thanks in advance.
zee944 is offline   Reply With Quote
Old 26th May 2011, 22:09   #2  |  Link
Dogway
Registered User
 
Join Date: Nov 2009
Posts: 2,361
edit:
Mergeluma(AddLumaCurve("full_flat.amp")) ?
__________________
i7-4790K@Stock::GTX 1070] AviSynth+ filters and mods on GitHub + Discussion thread
Dogway is offline   Reply With Quote
Old 26th May 2011, 23:38   #3  |  Link
IanB
Avisynth Developer
 
Join Date: Jan 2003
Location: Melbourne, Australia
Posts: 3,167
Modifying luma without regard to chroma as well can result in out of gamut values.

For example if Y=16, then U=128 and V=128 are the only valid in gamut values.

Out of gamut values have undefined behaviour when converted back to RGB for eventual display. Avisynth just clamps the individual R, G or B channels to be between 0 and 255 without regard to maintaining either luma, hue or saturation.

See U and V ranges for valid RGB and Understanding YUV, Luma, Luminance for a discussion about this.
IanB is offline   Reply With Quote
Old 28th May 2011, 11:33   #4  |  Link
zee944
Registered User
 
Join Date: Apr 2007
Posts: 240
Quote:
Originally Posted by Dogway View Post
edit:
Mergeluma(AddLumaCurve("full_flat.amp")) ?
Doesn't help. It's trickier than that.

Quote:
Originally Posted by IanB View Post
So then I need to substitute the out of gamut (invalid Y, U, V combinations) pixels with black?

How can I take the luma from one clip, the chroma from another clip and merge them together without having the side effects above? Is this calls for some lookup table for the invalid pixels, or is it simpler?
zee944 is offline   Reply With Quote
Reply

Tags
curve, gicocu, luma, yuv


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 18:34.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.