我正在尝试在 X 射线视频(灰色图像)中找到三个颈椎(C2、C3、C4)我正在使用 SURF 来识别有这 3 个椎骨的位置(所有这些椎骨的大框)
SURF 给了我很好在这种情况下导致
现在我正试图从这个大盒子中识别出这些椎骨中的每一个,但在这种情况下 SURF 失败了 SURF 在有 3 个椎骨的区域工作得非常好,但单独找到它们并不好
更新: SURF 的想法是找到图像中的重要关键点。因此,我使用这个想法在 2 个图像中找到关键点,然后找到这 2 个图像之间的匹配点。在我的程序开始时,用户选择了 4 个框。一个大盒子装所有的椎骨,另外三个。
我将使用这个选定的区域作为模板,在视频的下一个图像中找到它们。首先,我将应用 SURF 来找到所有椎骨的大盒子。这个代码很好用
现在我想在大盒子里找到三个小盒子,但 SURF 给了我不好的结果(错误的盒子)
照片向您展示了 4 个框(忽略左侧框和三个点)这是我正在使用的 4 个模板图像(裁剪 4 次后)
问题是,我怎样才能提高 SURF 结果以获得三个椎骨?
任何帮助将不胜感激:D
这是显示完美结果的图像....大盒子有3个盒子...

这是我正在使用的代码 第一个参数 (Mat img_object) 是我试图在 (Mat img_scene) 中找到的模板图像,第二个参数是有 3 个椎骨的大盒子,第三个参数是当我们找到它时我想在物体周围画一个盒子
CvRect Identify_SURF_Frame (Mat img_object , Mat img_scene , CvRect in_box)
{
cvNamedWindow("Good Matches & Object detection", CV_WINDOW_AUTOSIZE);
CvRect output_box;
//-- Step 1: Detect the keypoints using SURF Detector
int minHessian = 1; // I reduce this number so I can have a lot of number for keypoints
SurfFeatureDetector detector( minHessian , 2 , 3 , true , true );
std::vector<KeyPoint> keypoints_object, keypoints_scene;
detector.detect( img_object, keypoints_object );
detector.detect( img_scene, keypoints_scene );
//-- Step 2: Calculate descriptors (feature vectors)
SurfDescriptorExtractor extractor;
Mat descriptors_object, descriptors_scene;
extractor.compute( img_object, keypoints_object, descriptors_object );
extractor.compute( img_scene, keypoints_scene, descriptors_scene );
//-- Step 3: Matching descriptor vectors using FLANN matcher
BruteForceMatcher < L2 < float > > matcher;
std::vector< DMatch > matches;
matcher.match( descriptors_object, descriptors_scene, matches );
double max_dist = 0; double min_dist = 100;
//-- Quick calculation of max and min distances between keypoints
for( int i = 0; i < descriptors_object.rows; i++ )
{
double dist = matches[i].distance;
if( dist < min_dist ) min_dist = dist;
if( dist > max_dist ) max_dist = dist;
}
//-- Draw only "good" matches (i.e. whose distance is less than 3*min_dist )
std::vector< DMatch > good_matches;
for( int i = 0; i < descriptors_object.rows; i++ )
{
if( matches[i].distance < 4 * min_dist )
{
good_matches.push_back( matches[i]);
}
}
Mat img_matches;
drawMatches( img_object, keypoints_object, img_scene, keypoints_scene, good_matches, img_matches, Scalar::all(-1), Scalar::all(-1),
vector<char>(), DrawMatchesFlags::NOT_DRAW_SINGLE_POINTS );
//-- Localize the object
std::vector<Point2f> obj;
std::vector<Point2f> scene;
if (good_matches.size() >= 4)
{
for( int i = 0; i < good_matches.size(); i++ )
{
//-- Get the keypoints from the good matches
obj.push_back( keypoints_object[ good_matches[i].queryIdx ].pt );
scene.push_back( keypoints_scene[ good_matches[i].trainIdx ].pt );
}
Mat H = findHomography( obj, scene, CV_RANSAC );
//-- Get the corners from the image_1 ( the object to be "detected" )
std::vector<Point2f> obj_corners(2);
obj_corners[0] = cvPoint(0,0);
obj_corners[1] = cvPoint( img_object.cols, 0 );
//obj_corners[2] = cvPoint( img_object.cols, img_object.rows );
//obj_corners[3] = cvPoint( 0, img_object.rows );
std::vector<Point2f> scene_corners(2);
perspectiveTransform( obj_corners, scene_corners, H);
int x1 , x2 , y1 , y2 ;
x1 = scene_corners[0].x + Point2f( img_object.cols, 0).x ;
y1 = scene_corners[0].y + Point2f( img_object.cols, 0).y ;
x2 = scene_corners[0].x + Point2f( img_object.cols, 0).x + in_box.width ;
y2 = scene_corners[0].y + Point2f( img_object.cols, 0).y + in_box.height ;
rectangle(img_matches , cvPoint(x1, y1) , cvPoint(x2, y2) , Scalar( 255, 255, 255), 1 );
output_box.x = x1 - in_box.width ;
output_box.y = y1 ;
output_box.width = in_box.width ;
output_box.height = in_box.height ;
}
//-- Show detected matches
imshow( "Good Matches & Object detection", img_matches );
return output_box ;
}