Need Help with my Chroma Key Pixel Shader Algorithm

I’ve just uploaded a simple demo application that shows the Silverlight 3 Chroma Key Effect in action.  If you don’t have the Silverlight 3 beta installed you will need to install it from here (the install link in the application will not work). 

ChromaDemo.png

If you watch the demo, you’ll notice ghosting along the edges of the dancers – obviously I need help with my pixel shader algorithm:

 float4 PS( VS_OUTPUT input ) : SV_Target
{
     float4 color = tex2D( ImageSampler, input.UV );
   
     if (abs(InputColor.r - color.r) <= Tolerance && 
         abs(InputColor.g - color.g) <= Tolerance &&
         abs(InputColor.b - color.b) <= Tolerance)
     {
      color.rgba = 0;
     }
  
   return color;
 }

If anyone has suggestions on how to make this algorithm better – or has a better algorithm, please share it with me.

Thanks in advance.