特征点匹配检测(Matlab) 您所在的位置:网站首页 matlab多个图像特征匹配 特征点匹配检测(Matlab)

特征点匹配检测(Matlab)

2024-06-26 19:27| 来源: 网络整理| 查看: 265

借鉴大神的方法,实现特征点匹配检测,但是测试发现了一个问题,模板的图像大小变化的话,会导致匹配错误。

Using Da Shen's method for reference, the feature point matching detection was realized, but the test found a problem, if the image size of the template changed, it would lead to the matching error.

 CODE:

boxImage = imread('0.png'); sceneImage = imread('1.png'); boxImage = rgb2gray(boxImage); sceneImage =rgb2gray(sceneImage); %% Step 2: 提取SURF特征点 boxPoints = detectSURFFeatures(boxImage); scenePoints = detectSURFFeatures(sceneImage); %% Step 3: 根据特征点生成图像的特征向量 [boxFeatures, boxPoints] = extractFeatures(boxImage, boxPoints); [sceneFeatures, scenePoints] = extractFeatures(sceneImage, scenePoints); %% Step 4: 初步建立一个匹配对(含野值) boxPairs = matchFeatures(boxFeatures, sceneFeatures); %show matchedBoxPoints = boxPoints(boxPairs(:, 1), :); matchedScenePoints = scenePoints(boxPairs(:, 2), :); figure(1); showMatchedFeatures(boxImage, sceneImage, matchedBoxPoints,matchedScenePoints, 'montage'); title('Putatively Matched Points (Including Outliers)'); %% Step 5: 预测仿射变化,去除不满足变化的野值 [tform, inlierBoxPoints, inlierScenePoints] = estimateGeometricTransform(matchedBoxPoints, matchedScenePoints, 'affine'); figure(2); showMatchedFeatures(boxImage, sceneImage, inlierBoxPoints,inlierScenePoints, 'montage'); title('Matched Points (Inliers Only)'); %% Step 6:获取目标物的多边形框 boxPolygon = [1, 1;... % top-left size(boxImage, 2), 1;... % top-right size(boxImage, 2), size(boxImage, 1);... % bottom-right 1, size(boxImage, 1);... % bottom-left 1, 1]; % top-left again to close the polygon %Transform the polygon into the coordinate system of the target image. %The transformed polygon indicates the location of the object in the scene. newBoxPolygon = transformPointsForward(tform, boxPolygon); %Display the detected object. figure(3); imshow(sceneImage);hold on;line(newBoxPolygon(:, 1), newBoxPolygon(:, 2), 'Color', 'y'); title('Detected Box');

  I hope I can help you,If you have any questions, please  comment on this blog or send me a private message. I will reply in my free time.     

 

 

 

 



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有