View Full Version : Chroma key leftover dirt, spill, green color like halo, please help fix it
ijunkie
3rd July 2011, 05:27
Hello,
I am junkie and following this forum religiously for 2 months now. I saw lot of nice people here helping out others. It's nice to be here.
Coming to my problem me and my friends are doing a low budget web show and we ran into some chroma key problems. We cannot afford to buy expensive software now using xsplit to live stream to ustream and also record locally. We want to clean up the local copy and upload to youtube. That's about it as far as the back story goes.
Now the real issue is Xsplit is not so good or we have poor lighting we ended up with the video that has green aura/hallow all around the host on his hands also when they come into the view. Even hosts hair has green stuff on the edges in the back etc. You can see it in the attached images and sample video.
All I am looking is to make this video look good using Avisynth get rid of that green and dirt(honestly don't know what to call it) and get going.
I sincerely appreciate your help if you can.
http://db.tt/w4QXF2V Images
http://proudlycanadian.imgur.com/chromadirtspillgreen sample video
Advance wishes and happy July 4th. Yesterday was Canada day and we had lots of fun. Thanks again.
poisondeathray
3rd July 2011, 15:14
This is very difficult to "fix" properly after it's been keyed, even with specialized software
There is overlap in the hues so unless you plan on animating masks / rotoscoping, any corrections by secondary color correction or narrowing on the green spill will alter the colors of related hues like the subjects' jacket for instance
You usually need multiple mattes and multipass keying to salvage poorly shot greenscreen footage . A single pass key won't work very well.
This isn't something that's particularly easy to do in avisynth (masks, rotoscoping or keying)
Do you still have the unkeyed footage ? you have a higher change of salvaging that
ijunkie
3rd July 2011, 16:36
Thank you for replying poisondeathray.
I don't have unkeyed footage as it is streamed live with chroma keying. Even though this footage can't be fixed/salvaged completely now is there a chance of cleaning it up and making it look little more nicer? I also noticed the green stuff that is leftover is of different shades, what I mean by that is the color values(#codes) are all over. I think this difference in color values is called threshhold or tolerance not sure. I thought of two things to possibly solve this problem but no clue on how to proceed still thinking.
1) Identify the green(select a range of green like this # to this #)pixels and replace them with surrounding immediate neighboring pixels, few pixels away in any direction(may be 3-4 pixels away) that are not green(not with in our defined range of green)
2) Identify the green(select a range of green like this # to this #) pixels delete and mask them with the background image used in the footage.
Once we do any of that lastly smoothen the edges of hosts body(again no clue how to limit smoothing to edges of hosts body)
Using trevlac's TweakColor function I identified the problem pixels but when I play with hue they are turning to purple color but not to any color that is close to hosts hair :)
Used the code below
TweakColor(hue=-120,startHue=200,endHue=260)
Link to image that shows TweakColor identified pixels(I pointed to them with red arrows)
http://i.imgur.com/zsRyV.png
I have also tried to use the code below by IanB to make the problem pixels less visible but I see no effect or change, played with different sat and hue values here too.
http://forum.doom9.org/showthread.php?p=1174764#post1174764
...
greenHue=180 # Hue of leaking green
greenSat=100 # Saturation of leaking green
Tweak (sat=0, startHue=greenhue-2, endHue=greenHue+2, maxSat=greenSat+5, minSat=greenSat-5)
That's where I am working out on my own :), I searched all over Doom9 for similar problems that were solved before. As I am in learning mode the terminology is not known to me and using right terms to describe and search for a problem is little difficult but I am getting along. I am comfortable in doing things by example.
Thanks for your help.
poisondeathray
3rd July 2011, 17:17
Try playing with all the parameters, for example, changing saturation to zero in tweakcolor might look a little better
You might have to use several instances using different values to narrow in on different areas of green hue spills
To smoothen the edges you can try an anti-aliasing filter e.g AAA(), there are dozens more to choose from that might yield better results
To get rid of the flickering artifacts on the left (probably from the bad key), you can cover it up with a static image of the clean background (e.g. use crop() with stackhorizontal, or overlay() )
Yellow_
3rd July 2011, 22:36
You could download a build of Blender 2.58 from www.graphicall.org or www.blender.org, it's free and open source.
Load your video into the nodal compositor (32bit float linear) and use the Color Spill node. :-)
Just tried it and it seems to work a treat on your .avi without fiddling with the settings at all. :-)
Assuming you have one, subtract a clean copy of the "Issues that matter" background from the stream. You will end up with grey where the images match and other colours where the host is.
You can then key on that grey to get a 1st mask around the host. This should be analogous with the original green screen.
You can then expand that mask a little to get a 2nd mask. This mask should now include the boundary causing trouble.
If you remove the 1st mask from the 2nd, you will end up with a 3rd mask that will be a mask of just the boundary causing trouble.
You can now process just the boundary area.
Tricks to try on the boundary area might be lower the saturation, nuke all the green, blur it, anti-alias it, etc. you will just have to experiment to see what looks most reasonable.
You may need to hand paint the masks to remove any troublesome area like the flickering on the left side.
Masktools will be your best friend for these tasks.
ijunkie
4th July 2011, 02:51
Thank you IanB. Yes I have the original background used. I will try to do what you suggested, it looks very advanced to me but will try.
As a whole, yes it is fairly advanced but each step is fairly simple and you can build the whole lot one piece at a time, examining the intermediate result as you go.
Start with just :-
BGround=ImageSource("Issues that matter...", pixel_type="RGB32")
...Source("source...") # Read video stream!
ConvertToRGB32()
Subtract(BGround) # Grey where images match
See what you get, appreciate areas where the theory may fail. You may find unexpected discrepancies where you get compression artefacts in the background.
Next add this :-ResetMask() # Set all Alpha=255
ColorKeyMask($808080, 5, 5, 5) # Set Alpha=0 where colour matches. Adjust tolerances for reasonable result.
ShowAlpha() # Check what mask looks like
See what you get, appreciate areas where the theory has failed. Discuss the result for more ideas to improve the concept.
Read the Masktools documentation many times, more than one tool may do what you want. We probably want an impand or expand tool next.
ijunkie
4th July 2011, 16:53
Yellow_ thanks for your advice. I will use blender if I fail to succeed with Avisynth.
Thanks again IanB for the code I will be on it and will post the results soon.
ijunkie
5th July 2011, 23:53
I ended up with the code below
BGround=ImageSource("C:\Users\Media\Pictures\itm\issues_that_matter_bg_3_640x360.png", pixel_type="RGB32")
FGround=DirectShowSource("D:\test\sample1\chroma_dirt_leftover_green.avi") # Read video stream!
ConvertToRGB32(FGround)
Subtract(BGround) # Grey where images match
ResetMask() # Set all Alpha=255
maskclip=ColorKeyMask($3A5F48,10) # Set Alpha=0 where colour matches. Adjust tolerances for reasonable result.
Overlay(FGround,mask=ShowAlpha(maskclip), mode="blend", greymask=true,opacity=1)
Result is same as source. I am little clueless now masktools looks to be an awesome plugin but it is too complex for me at this stage, I am trying to grasp it.
I changed this
ColorKeyMask(0x808080, 5, 5, 5) # Set Alpha=0 where colour matches. Adjust tolerances for reasonable result.
I didn't understood what is 0x808080 color, when I use the code as it is I got error script cannot run, also didn't understood what setting alpha=0 and where I should set it.
I change the above code to this
ColorKeyMask($3A5F48,10) # Set Alpha=0 where colour matches. Adjust tolerances for reasonable result.
I changed color code to $3A5F48(which is like in between the green color range I am trying to get rid of) tolerance value above 10(read in the wiki that now all tolerances are represented as one parameter) is eating away subjects suit.
I am not sure where to go from here, meanwhile I am reading masktools documentation and trying to understand it thanks.
Small steps please, if you run you will trip. ;)
When you Subtract() two identical images you get a grey result, colour $808080. In your case where the BGround matches the FGround you should get grey, we want to "find" that area so we tell ColorKeyMask() to set the alpha channel to 0 where this occurs. Where they do not match you get some other colour, what colour it is we do not care, we just want the matching part at this point.
Start with just this. Prove that you get grey, $808080, where the images match and anything but grey where they do not match.BGround=ImageSource("C:\Users\Media\Pictures\itm\issues_that_matter_bg_3_640x360.png", pixel_type="RGB32")
FGround=DirectShowSource("D:\test\sample1\chroma_dirt_leftover_green.avi") # Read video stream!
ConvertToRGB32(FGround)
Subtract(BGround) # Grey where images match
If you are happy with the grey and anything but grey regions then move on to thisBGround=ImageSource("C:\Users\Media\Pictures\itm\issues_that_matter_bg_3_640x360.png", pixel_type="RGB32")
FGround=DirectShowSource("D:\test\sample1\chroma_dirt_leftover_green.avi") # Read video stream!
ConvertToRGB32(FGround)
Subtract(BGround) # Grey where images match
ResetMask() # Set all Alpha=255
ColorKeyMask($808080, 5, 5, 5) # Set Alpha=0 where colour matches. Adjust tolerances for reasonable result.
ShowAlpha() # Check what mask looks likeThe black region should be where you originally had Green screen, the white regions should be where the host was talking.
You may need to adjust the grey colour and/or the tolerance values to get the detection just right.
You do not need to use overlay yet, we are still trying to build a suitable mask to apply to just the green halo region.
Next we will use something from masktools to make the black region slightly larger, then we will turn the original black region white, leaving a black region that hopefully matches the area where you have green halo. Then we vandalise the green halo region and finally use overlay() or layer() to integrate the original stream with the repaired green halo region.
Also please publish C:\Users\Media\Pictures\itm\issues_that_matter_bg_3_640x360.png so we can compare your exact results. I assume D:\test\sample1\chroma_dirt_leftover_green.avi is the same as you published in the first post.
ijunkie
6th July 2011, 03:48
Thank you Ian I tried again, if I am using
ColorKeyMask(0x808080, 5, 5, 5)
there is some problem with the script I get "Script error: expected a, or) but when I change color to $808080 everything is fine.
BGround=ImageSource("C:\Users\Media\Pictures\itm\issues_that_matter_bg_3_640x360.png", pixel_type="RGB32")
FGround=DirectShowSource("D:\test\sample1\chroma_dirt_leftover_green.avi") # Read video stream!
ConvertToRGB32(FGround)
Subtract(BGround) # Grey where images match
ResetMask() # Set all Alpha=255
ColorKeyMask($003333, 20, 20, 20) # Set Alpha=0 where colour matches. Adjust tolerances for reasonable result.
ShowAlpha() # Check what mask looks like
With the above code I get some where close to where I want the black to be, tried different values but no avail :)
Yes the "chroma_dirt_leftover_green.avi" file is same as the sample. I have uploaded the background image "issues_that_matter_bg_3_640x360.png" putting the link below.
http://i.imgur.com/A2D2D.png
The black area sample image is below. it is frame no 374, every frame is different but this is the best I could do without affecting much of the other areas.
http://i.imgur.com/lZKhE.png
Thank you appreciate your help.
Oops sorry 0x808080 should be $808080, Doh! :o
I have fixed my posts.
Sir BlunderBrain
6th July 2011, 09:26
It seems like the background image and the background in the video doesn't quite line up. The background image is shifted one pixel to the right compared to the video, try this for a quick and dirty comparison.
BGround=ImageSource("C:\Users\Media\Pictures\itm\issues_that_matter_bg_3_640x360.png", pixel_type="RGB32").AddBorders(0,0,1,0).Crop(1,0,0,0)
Still looks like a challenge to get a clean mask though.
Yes not having the correct background image will be a show stopper. I haven't had a chance to look at it yet, latter guys......
ijunkie
6th July 2011, 20:19
Thank you for noticing that there is 1 pixel difference in the background image. I do not understand why, as it is the exact same image used in the video.
ijunkie
19th July 2011, 05:43
Hello again I am just wondering if my problem can be solved or not. I have an idea, masking is very difficult with my footage so I am thinking if any of you can help me find the edges around the host and then make a mask around those edges and separate the host from background, then overlay host onto the clean background image I posted here.
I have no clue how to achieve the above though, guidance is appreciated thanks.
vBulletin® v3.8.11, Copyright ©2000-2025, vBulletin Solutions Inc.