我实际上正在研究头部的轮廓检测。由于图片是在白墙前拍摄的,所以我决定在经过阈值处理的图片上运行一条蛇(主动轮廓模型算法)。
问题是蛇不能很好地贴合鼻子、嘴巴和嘴巴下方(如下图所示)。
//load file from disk and apply threshold
IplImage* img = cvLoadImage (file.c_str (), 0);
cvThreshold(img, img, 170, 255, CV_THRESH_BINARY);
float alpha = 0.1; // Weight of continuity energy
float beta = 0.5; // Weight of curvature energy
float gamma = 0.4; // Weight of image energy
CvSize size; // Size of neighborhood of every point used to search the minimumm have to be odd
size.width = 5;
size.height = 5;
CvTermCriteria criteria;
criteria.type = CV_TERMCRIT_ITER; // terminate processing after X iteration
criteria.max_iter = 10000;
criteria.epsilon = 0.1;
// snake is an array of cpt=40 points, read from a file, set by hand
cvSnakeImage(img, snake, cpt, &alpha, &beta, &gamma, CV_VALUE, size, criteria, 0);
我试图更改 alpha/beta/gamma 参数或迭代次数,但我没有找到比下面显示的输出更好的结果。我不明白为什么鼻子被割掉,脸不适合嘴巴。我猜我有足够的曲率点,但仍然有一些线由几个(> 2)点组成。
输入图像:
输出蛇:
蓝色:手动设置的点
绿色:输出蛇
任何帮助或想法将不胜感激。谢谢 !