computer vision - how to remove background image and get fore image -
there 2 images
alt text http://bbs.shoucangshidai.com/attachments/month_1001/1001211535bd7a644e95187acd.jpg alt text http://bbs.shoucangshidai.com/attachments/month_1001/10012115357cfe13c148d3d8da.jpg 1 background image 1 person's photo same background ,same size,what want remove second image's background , distill person's profile only. common method subtract first image second one,but problem if color of person's wear similar background. result of subtract awful. can not whole people's profile. have idea remove background give me advice. thank in advance.
if have estimate of image background, subtracting image person first step. first step. after that, have segment image, i.e. have partition image "background" , "foreground" pixels, constraints these:
- in foreground areas, average difference background image should high
- in background areas, average difference background image should low
- the areas should smooth. outline length , curvature should minimal.
- the borders of areas should have high contrast in source image
if mathematically inclined, these constraints can modeled mumford-shah functional. see here more information.
but can adapt other segmentation algorithms problem.
if want fast , simple (but not perfect) version, try this:
- subtract 2 images
- find largest consecutive "blob" of pixels background-foreground difference greater threshold. first rough estimate "person area" in foreground image, segmentation not meet criteria 3 , 4 above.
- find outline of largest blob (edit: note don't have start @ outline. can start larger polygon, steps automatically shrink optimal position.)
- now go through each point in outline , smooth outline. i.e. each point find point minimizes formula: c1*l - c2*g, l length of outline polygon if point moved here , g gradient @ location point moved to, c1/c2 constants control process. move point position. has effect of smoothing contour polygon in areas of low gradient in source image, while keeping tied high gradients in source image (i.e. visible borders of person). can try different expressions l , g, example, l take length , curvature account, , g take gradient in background , subtracted images account.
- you have re-normalize outline polygon, i.e. make sure points on outline spaced regularly. either that, or make sure distances between points stay regular in step before. ("geodesic snakes")
- repeat last 2 steps until convergence
you have outline polygon touches visible person-background border , continues smoothly border not visible or has low contrast. "snakes" (e.g. here) more information.
Comments
Post a Comment