View Full Version : How to replace one color to another ...?
ruanova
21st January 2005, 09:38
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 .....
esby
21st January 2005, 18:42
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
ruanova
24th January 2005, 13:07
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.....
Si
24th January 2005, 23:41
I've put together a simple plugin that should do what you want
Try getting it from here (right-click and use save as) (http://www.geocities.com/siwalters_uk/changecolour01.zip)
regards
Simon
ruanova
25th January 2005, 08:53
Ohhhhh babe , that's all I need .....!!!
Thanks, great job for me...
(? Any information with param3 and param4 ...?)
Thanks again
Si
25th January 2005, 19:11
(? 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
Wilbert
25th January 2005, 21:22
1) Tolerance would be useful (like ColorKeyMask).
2) YUY2 support.
trolltuning
27th January 2005, 22:28
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?
trevlac
28th January 2005, 19:19
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
28th January 2005, 20:24
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. :D
trolltuning
28th January 2005, 21:59
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...:)
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.