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. Domains: forum.doom9.org / forum.doom9.net / forum.doom9.se |
|
|
#1 | Link |
|
Registered User
Join Date: Oct 2001
Posts: 29
|
Black and White, color masking?
I need some help here. I am trying to convert a clip I have to black and white, with the exception of maybe one specific color. Something similar to the effect in schindlers list with the one girl with a red coat and some of those gatorade commercials.
I was looking into doing layering, and masking, using colorkeymask, but I am pretty much completely stumped. At current I have two clips, one in color and the other in grayscale. I really just dont understand the masking and how it works how to select a color, then mask the image so only that part shows up over the black and white. |
|
|
|
|
|
#2 | Link |
|
Avisynth Developer
Join Date: Jan 2003
Location: Melbourne, Australia
Posts: 3,167
|
Code:
AviSource(...) # Whatever # Change to pixel format with an Alpha channel ConvertToRGB32() # Save coloured version of clip CV=Last # Set alpha to all opaque ResetMask() # Make alpha transparent where colour is "interesting" ColorKeyMask($456789, 5) # Strip colour from clip (keep alpha channel) BWa=Grayscale() # Apply B/W image where alpha is opaque # Let colour image show thru where alpha is transparent. Layer(CV, BWa, "Add", 255) The Overlay() verb should also be able to do this with better control but currently seems to have a bug that I will have to find and fix. So Layer() it will have to be. IanB |
|
|
|
|
|
#3 | Link |
|
Registered User
Join Date: Oct 2001
Posts: 29
|
Thank you! that was exactly what i was looking for, but one more question about colorkeymask. The number you specified for the color, what kind of format is that in? and how to choose which color responds to which number? for now, i will just randomly play with it.
Thanks again |
|
|
|
|
|
#4 | Link |
|
Avisynth Developer
Join Date: Jan 2003
Location: Melbourne, Australia
Posts: 3,167
|
ColorKeyMask(int Color, int Tolerance)
Color is an integer RGB value calculated by (R<<16 | G<<8 | B), individual values between 0 and 255. Tolerance specifies the range for which close colours are considered the same. For easy expression Hex format is used by prefixing a $ thus $FF0000=red, $00FF00=Green & $0000FF=Blue. Take a look at colors_rgb.avsi installed in your avisynth plugin directory for a stack of predefined standard colours and some URLs for even more. Also Mask() and ShowAlpha() can be used to insert and extract the alpha channel from a separate clip. You are probably going to need to do this. Usually very strong filtering is required to create a stable and reliable mask for what you are doing. Sometimes generating the mask as a clip, saving it and hand painting out the inevitable flecks of false elements that occur is required. IanB |
|
|
|
|
|
#5 | Link |
|
Fascinated Lurker
Join Date: Feb 2002
Location: Durham, UK
Posts: 243
|
You can also do this with the filter tweakcolor which allows you to apply Tweak to hue ranges such as:
TweakColor(sat=0,startHue=0,endHue=90) TweakColor(sat=0,startHue=130,endHue=359) which should give you reds and skin tones. Operates in YV12 only. |
|
|
|
|
|
#6 | Link | |
|
Registered User
Join Date: Oct 2001
Posts: 29
|
Quote:
|
|
|
|
|
![]() |
|
|