Opencv - Active contours

烂漫一生 提交于 2019-12-11 12:44:39

问题


I am trying to use the active contour algorithm using OpenCV function. There is an implementation named cvSnakeImage. But I can't find an example in the OpenCV documentation. I found an example here. I added some lines and I expect that this code segments the image but the result is not expected. The points from snake method don't move.

I edited a function from this code. And it is here :

void AactiveSnake(IplImage* image)
{

points = (CvPoint*)cvAlloc(15*sizeof(CvPoint*));
int x,y;
for(int i = 0;i < 14 ; i++){    
    x = Xvalues[i];
    y = Yvalues[i];
    points[i].x = x;
    points[i].y = y;
}
cout << "AactiveSnake";
cvSnakeImage(image,points,15,&Alfa,&Beta,&Gamma,CV_VALUE,win,criteria,0);

IplImage* temp;
temp = cvCloneImage(imageRGB);
for(int i = 0;i < 14 ; i++){    
    x = points[i].x;
    y = points[i].y;
    Xvalues[i] = x;
    Yvalues[i] = y;
    cvCircle(temp,cvPoint(x,y),1,CV_RGB(255,0,0),-1);       
}
cout << "*\n";
cvShowImage( "Snake-Points", temp );
waitKey(0);

}

Input image :

来源:https://stackoverflow.com/questions/29031909/opencv-active-contours

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!