Remove the background of an image
4 views (last 30 days)
Image Analyst on 27 Oct 2015
First of all, fix your horrible image capture conditions. I mean, why have a strong light coming in from the side that creates huge dynamic range and strong deep shadows. Get a uniform background. This is an easy thing to do photographically. Secondly, use a color camera - it will be easier to find the uniform background in that case. Post an image like that once you have it and then we can proceed.
Aj_ti on 9 Oct 2016
Edited: Aj_ti on 9 Oct 2016
I can't say this is the best way, but I'm currently apply this to crop the face images, removing the background and hair part as shown in the picture below:
This my reference image.
What I did is I crop (manually, using photo editor) 1 face image as a reference. Then, I apply feature point detection on the face and make 6 points as reference points (I'm using the points on eyes). Doing the same for other face images that you want to process to get the 6 points. Lastly, perform/calculate the geometric transformation as the code below and perform image warp.
[tform,inlierPtsDistorted,inlierPtsOriginal] = estimateGeometricTransform(matchedPtsDistorted,matchedPtsOriginal,'similarity');
outputView = imref2d(size(ori));
Ir = imwarp(img,tform,'OutputView',outputView);
This image shows points matching between reference image and probe image.
The result is as follow:
Regarding the illumination issue, histogram equalization or Retinex able to solve it. There are a lot of algorithm for illumination normalization.