Log in

View Full Version : Process greens separetaly from the rest of the Image.


anton_foy
24th June 2007, 17:28
I want to treat the green parts in the image in one way, then overlay it after I treated the other parts of the image with different filters.

For example:

1) "The whole image(including greens)": Deinterlace and sharpen

2) "The Greens(only)": Curves and grain

3) "The whole image(without greens)": Curves and rgbadjust

4) Overlaying the (step 2) green parts over the image.

Someone know if this can be done in one script?

Thanks in advance!

Leak
24th June 2007, 17:46
I want to treat the green parts in the image in one way, then overlay it after I treated the other parts of the image with different filters.
You can use ConvertToRGB32 and ShowRed/ShowGreen/ShowBlue to split an image into 3 YV12 clips where the luma stores the red, green and blue channel. Filter those separately, then use MergeRGB to go merge them together. If you just want to remove the greens from a clip you can use a black clip for the green channel in MergeRGB as well.

np: Lusine - Auto Pilot (Deru Remix) (Podgelism)

anton_foy
24th June 2007, 22:11
Thank you for answering Leak



Tdeint or Yadif
Denoise

converttorgb32().ShowBlue("rgb32").ShowRed("rgb32")
Converttoyv12()


AddGrainC(15,1,0).
ConvertToRGB24.GiCoCU("C:\3.amp",photoshop=true)
Converttoyv12().Tweakcolor(hue=5)

converttorgb32().Showgreen("rgb32")#"YV12"
Converttoyv12()
o = last
g = o .mt_lut( Y=-128 )
g = g .AddGrainC(15,1,0)
mt_makediff( o, g, U=2,V=2 )
ConvertToRGB24.GiCoCU("C:\2.amp",photoshop=true)
Converttorgb32().MergeRGB(ShowBlue("rgb32"),ShowRed("rgb32"), showGreen("rgb32"))
Converttoyv12()

This makes Virtualdub exit without notice.
Should be MergeARGB?

IanB
25th June 2007, 00:26
RTFM!

Like this...
ConvertToRGB()
R=ShowRed("YV12")
B=ShowBlue("YV12")
ShowGreen("YV12")
....
MergeRGB(R, Last, B)

anton_foy
25th June 2007, 08:16
IanB thank you but it still does not work and I noticed how sleepy/sloppy I was when typing my script in here.
Here is what I tried...


Tdeint or Yadif
Denoise

### Processing Red and Blue ###

ConvertToRGB()
R=ShowRed("YV12")
B=ShowBlue("YV12")
Converttoyv12()


o = last
g = o .mt_lut( Y=-128 )
g = g .AddGrainC(15,1,0)
mt_makediff( o, g, U=2,V=2 )
ConvertToRGB24.GiCoCU("C:\3.amp",photoshop=true)
Converttoyv12().Tweakcolor(hue=5)


### Processing Green ###

converttorgb()
ShowGreen("YV12")
Converttoyv12()

o = last
g = o .mt_lut( Y=-128 )
g = g .AddGrainC(15,1,0)
mt_makediff( o, g, U=2,V=2 )
ConvertToRGB24.GiCoCU("C:\2.amp",photoshop=true)


### Merging RGB ###

Converttorgb().MergeRGB(R, Last, B)
Converttoyv12()


Virtualdub ERROR: Avisynth failure, mergeRGB: G must have same colorspace as R
I thought it has the same colorspace already?

foxyshadis
25th June 2007, 09:56
You aren't even processing R or B at all - they aren't being referenced afterward. Here's a method I'd use:

o=last
AddgrainC(15,15) # thought you didn't want grain on the r/b?
ConvertToRGB24.GiCoCU("C:\3.amp",photoshop=true).Converttoyv12() # are you sure you want to run the curves after the grain?
Tweakcolor(hue=5)
R = ShowRed("YV12")
B = ShowBlue("YV12")
o
AddgrainC(15,15)
ConvertToRGB24.GiCoCU("C:\2.amp",photoshop=true)
G = ShowGreen("YV12")
MergeRGB(R,G,B)
Converttoyv12()

IanB
25th June 2007, 11:19
... mergeRGB: G must have same colorspace as RThis is not one of my error messages. What version of Avisynth are you running and/or whose MergeRGB filter are you using? Use the native one from 2.56 or latter (cleanup plugin folder ???).

Whats with all the MT_stuff it does not make any sense. Pixel values within a Clip must be between 0 and 255.
Tdeint or Yadif
Denoise

O=Last # Save a copy for latter

### Processing Red and Blue ###
Tweakcolor(hue=5) # Do while still YUV, If possible

ConvertToRGB24() # Do 1 colourspace change only!

GiCoCU("C:\3.amp",photoshop=true)
RB=Last # Leave as RGB24, will use R & B

### Processing Green ###
O.AddgrainC(15,15)

ConvertToRGB24

GiCoCU("C:\2.amp",photoshop=true)
G = Last # Leave as RGB24, will use G

# Take R from red of RB
# Take G from green of G
# Take B from blue of RB
MergeRGB(RB, G, RB) # Output will be RGB32
ConvertToYV12()

... .Converttoyv12()
Tweakcolor(hue=5)
R = ShowRed("YV12")ShowRed needs RGB input.

Didée
25th June 2007, 11:44
Whats with all the MT_stuff it does not make any sense. Pixel values within a Clip must be between 0 and 255.
You're referring to mt_lut(Y=-128)? That does make sense, in fact. In mt_lut/xy, [plane] = -[value] means "set all pixels' [plane] component to abs([value])".

IanB
25th June 2007, 14:50
@Didée, No, I was refering to whole effect of the chain, and yes, I can now see I have worded my post poorly....
o = last
g = o .mt_lut( Y=-128 )
g = g .AddGrainC(15,1,0)
mt_makediff( o, g, U=2,V=2 )
ConvertToRGB24. ...i.e. Slowly add grain noise to the luma channel then convert to RGB. Why not just a straight AddGrainC(15,0,0) if the luma only mattered, which it doesn't because of the convertion to rgb.

anton_foy
25th June 2007, 17:47
Thank you all this is now working but it is not giving me the right effect. Why I want to process the green areas seperately is because I use a curve that is making the greens turn to yellow/brown. All other colors get the right look except the greens.
I think this(processing the whole green plane) may not be the way to go. Maybe only process a certain range from the green plane would do this but I will experiment with what you gave me. I appreciate it very much.



o = last
g = o .mt_lut( Y=-128 )
g = g .AddGrainC(15,1,0)
mt_makediff( o, g, U=2,V=2 )

Is for testing, resize the grain and all sorts of things for different looks of the grain and yes, to get better grain look I must use it before any curves.

IanB
25th June 2007, 23:39
Sounds like you should be abusing chroma keying to select the area where the colour is wrong. Put up a before and after frame grab of the problem.

espy2
11th October 2007, 08:04
Hi,

GiCoCu is not working correctly for me on either of two computers. It appears from this thread that others have had more "luck". I made a posting in a more directly relevant thread some weeks ago but no fix has so far been obtained from this route. So I try asking here.

I have GiCoCu 2005-06-20 downloaded from avisynth.org/warpenterprises under AviSynth v2.57 (Final) on Windows XP (SP2 etc.).

With Gimp '.cur' files GiCoCu makes everything go mostly yellowish (with a hint of green), apart from edges of objects and pure black which both become white and also there are some splodges of pale yellowy-red around the image that don't correspond to anything obvious in the original image but might possibly be repeating like contour lines. On the other hand, with PhotoShop '.amp' files (and photoshop=true) GiCoCu makes hardly any obvious change to the original image, though there are sometimes some green splodges and there may possibly be a slight change in levels.

In either case (".cur" or ".amp"), playing with different values for the "photoshop", "alpha" and "hsv" flags makes no difference to the result.

Anyone who has managed to get GiCoCu working properly, please what is your version of it and what is your setup? Or, has anyone else experienced this or can suggest the likely cause?

Thanks for any tips, I have spent many hours trying to fix this problem.

Mug Funky
13th October 2007, 09:48
anton: sounds like you need a tape-to-tape grade done :)

fwiw, i've had a couple of half-arsed attempts at coming up with a decent vector-selector in avisynth (ie, selecting a specific, soft edged range in HSV space). it's of limited use because of only having 8 bit yv12 to work with (8 bit RGB at best, but very slow, and not as good as 10-bit 4:4:4 with 32 bit processing obviously).

i don't have anything usable yet :)

anton_foy
14th October 2007, 20:36
@ Mug Funky

Your vector-selector sounds like good fun and might come in handy. :)
If you finish it I really want to try it out asap.

Keep up the colour-gradin' ;)

Mug Funky
20th October 2007, 09:32
here's half of it:

function ShowHue (clip c)
{

trig1="y 128 - 128 / x 128 - 128 / / atan 40.744 *"
trig2="128 y 128 - 128 / 128 x - 128 / / atan 40.744 * -"
trig3="128 128 y - 128 / x 128 - 128 / / atan 40.744 * -"
trig4="256 128 y - 128 / x 128 - 128 / / atan 40.744 * -"

trigUp="x 128 >= "+trig1+" "+trig2+" ? "
trigDown="x 128 >= "+trig4+" "+trig3+" ? "

hues=c.tweak(hue=108.5,coring=false)
mt_lutxy(hues.utoy(),hues.vtoy(),expr="y 128 >= "+trigUp+" "+trigDown+" ? ")
}

function ShowSat (clip c)
{
hues=c.tweak(hue=108.5,coring=false)
mt_lutxy(hues.utoy(),hues.vtoy(),expr="x 128 - 128 / 2 ^ y 128 - 128 / 2 ^ + .5 ^ 256 *")
}

this, combined with "greyscale" and some fancy lutting will let you create masks based on specific hue/sat/lum ranges.

resolution is crap obviously, due to 8 bit 4:2:0 being used... but even in 10-bit log these selectors can get pretty noisy.

next up i'll write a friendlier function that actually generates the mask, with presets for red, green, blue, cyan, magenta, yellow - this gives you the same sort of colour selection you'd get from a stock-standard telecine machine, which is not to be frowned on really, as these are very useful on their own.

[edit]

this handy line will give you a half-size mask showing everything green, from greenish-yellow to greenish-cyan:

showhue().mt_lut("256 x 86 - abs 256 43 / * -")

you can then upsize this (probably denoise first), and use it to overlay a changed clip with an unchanged clip.

i'll post more info on how this works when i've got something MUCH friendlier worked out, but the idea is your colours lie in a circle with red at 0 degrees.

all angles are scaled by 256/360 and the 6 main colours are 60 degrees apart, obviously (meaning they're ~ 43 "8-bit degrees" apart).

i'm just trying to figure out a nice way to "wrap" values from 0 to 255 smoothly, so i can key reds without my head asplode.