Algorithm to set Face image background to transparent

Algorithm to set Face image background to transparent

Post by harishashi » Tue, 23 May 2006 14:53:39

I am writing a program in C# that print face image. One of the
requirement is to have a transparent background so that when the image
is printed no ink is wasted for the background (no color result to no
ink used).

My problem at the moment is how to set those background to transparent.
I am using light blue background. The result is somewhat not perfect.
The problem is:

1. Light cause the background to have different shade.
2. I have tried to programmatically replace a range of color using C#.
For instance, instead of replacing blue pixel I try to replace a range
of RGB value that is nearby to blue. But the result is also not so
nice. Particularly at the edge of the person face and body.

At this moment I am looking for the following

A. Tips on software codes/algorithm. For instance how to effectively
replace the color and how to handle the edge.
B. Physical picture capture setting and technique. How to set the
camera, light and background.
C. Is there digital camera that can do this out of the box? That is,
output a face photo with perfect blue/magenta background.
D. I am also considering SDK or libraries that can do this in a very
fool proof manner.

Thanks in advance.

 
 
 

Algorithm to set Face image background to transparent

Post by harishashi » Tue, 23 May 2006 15:00:20

I would like to add here that the photo is a standard passport photo.

 
 
 

Algorithm to set Face image background to transparent

Post by vonschwart » Tue, 23 May 2006 22:31:55

Perhaps if you convert to HVS or similar colorspace it will work
better? The problem you are having is that the different shades you
see in the background are lighting effects, and don't really affect the
hue. Using a colorspace that separates the hue should make this a bit
easier.

duane
 
 
 

Algorithm to set Face image background to transparent

Post by drsiv » Wed, 24 May 2006 18:44:19

Sairam. Perhaps you can use a programme like irfanview or photoshop
to just ivert the colors just before printing. This is what we used to
save background color printing wastage in our Scintigraphy images once
upon a time. But now we have gone completely online. Regards
Dr.V.SIVA
 
 
 

Algorithm to set Face image background to transparent

Post by ImageAnaly » Fri, 26 May 2006 02:59:43

Not sure I exactly understand what's going on. Let me summarize as I
understand it. You are taking a photo of a person standing in front of
a light blue backdrop. The backdrop varies in color due to shadows,
non-flatness (is that a word?) of it, etc. You want to segment the
image into person and background, and then print out only the person.
Is that correct? (At first I wasn't clear if "background" was the
backdrop behind the person, or the pattern/color of the sheet you are
printing on).

Can't you just do a color classification to find a certain color range
(say light blue), and then clean up the image a bit (keep only the
largest blob so there are no light blue points on the person's
clothing, then fill holes in that blob to get a completely solid
background blob). Then you just replace those background blob pixels
with white (System.Drawing.Color.White) and then print. White pixels
won't lay down any ink and won't obscure any color or pattern you may
have on your printing substrate.

Regarding your A. Once you find the background, you'll need to clea it
up a bit to extend any pixels within a certain distance of the image
edges to be background - in case some part near the edge of the image
were not selected initially by color because it was in a shadow. Then
you'll need to find edges of the background blob that are not image
edges - these will be edges that meet the edge of the person's
silouhette. Then use that edge (enlarged a bit) as a mask to blur the
person's edges. This will blur just the person's edges (and not the
middle of the person) a bit so as to not get sharp jaggies when
printed. You could segment the image into just two blobs - the
background color and non-background color. Keep the largest two blobs.
This should be the background and the person. Then do a hole filling
to get rid of any color islands that are mixed in the wrong blob. Then
binarize those two and dilate each and find the overlap (union). This
overlap area is where the person's edge meets the background edge and
this is what you want to use as a mask for blurring the person blob.

There are many companies that produce small systems for printing ID
badges (or drivers licenses) that do something similar but I don't
think any cheap standalone cameras do this.