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

 

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

Reply
 
Thread Tools Search this Thread
Old 4th May 2005, 07:29   #1  |  Link
Mustachio
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.
Mustachio is offline   Reply With Quote
Old 5th May 2005, 09:01   #2  |  Link
IanB
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 clip applied to ColorKeyMask() may need some heavy processing to make the "interesting" colour easily selectable.

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
IanB is offline   Reply With Quote
Old 5th May 2005, 12:49   #3  |  Link
Mustachio
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
Mustachio is offline   Reply With Quote
Old 5th May 2005, 13:21   #4  |  Link
IanB
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
IanB is offline   Reply With Quote
Old 5th May 2005, 14:46   #5  |  Link
zettai
Fascinated Lurker
 
zettai's Avatar
 
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.
zettai is offline   Reply With Quote
Old 5th May 2005, 17:09   #6  |  Link
Mustachio
Registered User
 
Join Date: Oct 2001
Posts: 29
Quote:
Originally posted by IanB
Sometimes generating the mask as a clip, saving it and hand painting out the inevitable flecks of false elements that occur is required.

IanB
Yea, I was talking to my friend who I am working on these projects with, and he was the one that brought it up, but he didnt want to do it because he thought the masks would have to be all hand drawn. However, I think with your help, and zettai for TweakColor, I think I should be more than good to go in achieving what I need. Thanks guys
Mustachio is offline   Reply With Quote
Reply


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 01:10.


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