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

Reply
 
Thread Tools Search this Thread Display Modes
Old 21st January 2005, 09:38   #1  |  Link
ruanova
Registered User
 
Join Date: Mar 2003
Location: Santiago de Compostela (Spain)
Posts: 27
How to replace one color to another ...?

Hi, I'm looking for a script / plugin / ... to replace pixel color to another color ...

Example: my short video have a red color in the backgroung and I need to change this color to green ...

Thanks to all replies .....
ruanova is offline   Reply With Quote
Old 21st January 2005, 18:42   #2  |  Link
esby
Registered User
 
esby's Avatar
 
Join Date: Oct 2001
Location: france
Posts: 521
Search in the documentation for the Layer() function.
with colorKeyMask()

Basically you need to create a green clip,
and overlay the red part with layer.
Now be warned that it might work well on artificially produced color but not very much on other type of colors.
(eg: something that 'looks' red...)
There might be other filters that can do what you want,
but depending of what are your exact needs.


esby
__________________
http://esby.free.fr/
esby is offline   Reply With Quote
Old 24th January 2005, 13:07   #3  |  Link
ruanova
Registered User
 
Join Date: Mar 2003
Location: Santiago de Compostela (Spain)
Posts: 27
Thanks esby ...

I know this functions, but I need something like this:

Funtion ChangeColor( clip clip, HexOriginalColor, HexFinalColor ){}


--code?---

FinalColor = $000000

clip=AVISource("myclip.avi")

# Change all this colors to $000000
vidColor1 = ChangeColor(clip, $0C090A, FinalColor)
vidColor2 = ChangeColor(vidColor1, $0C090A, FinalColor)
vidColor3 = ChangeColor(vidColor2, $0C090B, FinalColor)
FinalClip = ChangeColor(vidColor3, $0C090D, FinalColor)


return FinalClip



Thanks.....

Last edited by ruanova; 24th January 2005 at 13:09.
ruanova is offline   Reply With Quote
Old 24th January 2005, 23:41   #4  |  Link
Si
Simply me
 
Si's Avatar
 
Join Date: Aug 2002
Location: Lancashire, England
Posts: 610
I've put together a simple plugin that should do what you want

Try getting it from here (right-click and use save as)

regards

Simon
Si is offline   Reply With Quote
Old 25th January 2005, 08:53   #5  |  Link
ruanova
Registered User
 
Join Date: Mar 2003
Location: Santiago de Compostela (Spain)
Posts: 27
Ohhhhh babe , that's all I need .....!!!
Thanks, great job for me...

(? Any information with param3 and param4 ...?)


Thanks again
ruanova is offline   Reply With Quote
Old 25th January 2005, 19:11   #6  |  Link
Si
Simply me
 
Si's Avatar
 
Join Date: Aug 2002
Location: Lancashire, England
Posts: 610
Quote:
(? Any information with param3 and param4 ...?)
I just quickly used my basic template to get something working.

If the plugin works OK, I'll change to using named parameters.

Any idea's about improving it would be welcome

regards

Simon
Si is offline   Reply With Quote
Old 25th January 2005, 21:22   #7  |  Link
Wilbert
Moderator
 
Join Date: Nov 2001
Location: Netherlands
Posts: 6,308
1) Tolerance would be useful (like ColorKeyMask).
2) YUY2 support.
Wilbert is offline   Reply With Quote
Old 27th January 2005, 22:28   #8  |  Link
trolltuning
Registered User
 
Join Date: Dec 2003
Posts: 215
Sorry for the dumb question but- how do we use this plugin? Where are the paramaters explained?

Also any advise on obtaining the hex values of the original clip that we want to change?
trolltuning is offline   Reply With Quote
Old 28th January 2005, 19:19   #9  |  Link
trevlac
budala
 
Join Date: Oct 2003
Location: U.S.
Posts: 545
Quote:
Originally posted by trolltuning
Sorry for the dumb question but- how do we use this plugin? Where are the paramaters explained?

Also any advise on obtaining the hex values of the original clip that we want to change?
Param1 is the original color. Param2 is the color you want it to be. Params 3&4 do nothing.

The colors (and clip colorspace) is RGB. So the hex values are RGB colors. RRGGBB where each pair runs 0-255 or 00 to FF in hex. I believe Simon has a vdub color picker that would give you the values. Any tool with a color picker would work.

-----------------------------

It was nice of Simon to put this together for the requester and it sounds like it is what that person needed. However, if I may comment on the troubles with this approach. Unless the colors are pure it's a bit of a pain to specify them all (as Wilberts tolerances comment). Plus, even specifying tolerances (especially in RGB) would be hard.

---------------------
I worked on this problem a bit ago with a filter that started with tweak and added some color adjustments. I called it tweakcolor. Here is the 1st thread ... but I think I explained it a few times if you search for tweakcolor:
http://forum.doom9.org/showthread.php?s=&threadid=74334

This filter works in YUY2 and does some interpolation so there are no sharp intensity/saturation changes, like you might get if you only pick 1 color or even a range.

I mainly use this to change the saturation of just a specific color (like red), but you can also use it to swing the hue around. I believe I put a bunch of examples in the zip file.
trevlac is offline   Reply With Quote
Old 28th January 2005, 20:24   #10  |  Link
trevlac
budala
 
Join Date: Oct 2003
Location: U.S.
Posts: 545
Ha!

I read about Tweakcolor and found it all to be a bit confusing. Plus, I couldn't find some stuff I know I put out there.

Anywho .... try tweak the internal avs filter 1st. This will let you change the hue ... and you might get the idea.

Look at doom9 analog capture guide section 15 for some more info on color. There is a color wheel there. 0 degrees is at 3 o'clock.

Next try tweakcolor ... here is an example explained


## Change Green Range to Red ##
TweakColor(hue=-120,startHue=200,endHue=260)

Green is a hue of 230 degrees (about 7 o'clock). Give it a range to get the green like colors of 200 to 260.

Tweak says it will change the hue by -180 to 180 degrees. Red is 110 degrees (11 o'clock). We want to swing from 7 to 11 or from 230 degrees to 110 degrees.

Please note that the degrees on the color wheel don't match a clock that well because they don't start at the same point and the numbers go opposite directions. 0 deg is 3:00, 90 deg is 12:00, 180 deg is 9:00, 270 deg is 6:00, 359 deg is just after 3:00. Best to forget the clock, look at the color wheel and draw a circle on some paper.

So ... AVS Tweak doc says "Positive values shift the image towards red. Negative values shift it towards green. "

We want to go from green to red or 230 to 110. It's fairly clear to me that this is a 120 degree shift. Positive or negative seems unclear. But I believe when DG made Tweak he just drew a horizontal line across the color circle and said if you move counter clockwise it is positive and clockwise it is negative. In this case moving blue counter clockwise (positive) would make it more red, and moving blue clockwise (negative) would make it more green.

So ... we no doubt want to move clock wise from 230 to 110 or negative 120.

To summarize TweakColor(hue=-120,startHue=200,endHue=260) means move a hue range of 200 to 260 (green) clockwise (negative) around the color wheel 120 degrees to where red lives. And the greens will be red.

To really do this you probably want to only go after certain intensities/saturations of green (like the bright greens) you need to muck with the sat/intsity start and end values for that.

------------------

Hope this helps someone. It can't be really that hard if I figured it out.
trevlac is offline   Reply With Quote
Old 28th January 2005, 21:59   #11  |  Link
trolltuning
Registered User
 
Join Date: Dec 2003
Posts: 215
Wow Tweakcolor is awesome-no more ugly colored shirts in my videos.
Now if some one could just write a filter that replaces strobed out checked shirts and striped shirts...
trolltuning is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 09:26.


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