I am trying to segment the hand from this depth image:
I tried watershed, region growing, grabcut, but all of them failed mainly because there is not a clear edge. I tried to sharp the image as well, but it didn't give me good results either.
I am trying to segment the hand from this depth image:
I tried watershed, region growing, grabcut, but all of them failed mainly because there is not a clear edge. I tried to sharp the image as well, but it didn't give me good results either.
This might not be the answer you were hoping for, but it might help you step forward a bit. Since I only provide algorithmic hints I will use Matlab rather than opencv.
Since this is not an ordinary intensity image, but rather depth image, you should use the implied geometry of the scene. The key assumption that can help you here is that the hand is resting on a surface. If you can estimate the surface equation, you can detect the hand much easier.
[y x] = ndgrid( linspace(-1,1,size(img,1)), linspace(-1,1,size(img,2)) );
X = [reshape(x(101:140,141:180),[],1), reshape(y(101:140,141:180),[],1), ones(1600,1)];
srf=(X\reshape(img(101:140,141:180),[],1)); %// solving least-squares for the 40x40 central patch
aimg = img - x*srf(1) - y*srf(2) - srf(3); %// subtracting the recovered surface
Using median filter to "clean" it a bit, and applying a simple thereshold
medfilt2(aimg,[3 3]) < -1.5
Yields
Not exactly what you were hoping for, but I think it's a step forward ;)
PS,
You might find the work of Alpert, Galun, Nadler and Basri Detecting faint curved edges in noisy images (ECCV2010) relevant to your problem.
Please check my code implementation.
void applyClahe(const cv::Mat& src, cv::Mat& dst)
{
cv::Mat lab;
cv::cvtColor(src, lab, cv::COLOR_BGR2Lab);
vector<cv::Mat> labChannels;
cv::split(lab, labChannels);
auto clahe = cv::createCLAHE();
cv::Mat cl; clahe->apply(labChannels[0], cl);
cl.copyTo(labChannels[0]);
cv::merge(labChannels, dst);
cv::cvtColor(dst, dst, cv::COLOR_Lab2BGR);
}
This function will give you the following result and good starting point.