RMSE for SIFT Algorithm
3 次查看(过去 30 天)
显示 更早的评论
I work with the vl_sift algorithm.How can I calculate RMSE to match two images? second image is projective transform to the first image.
I1 = imread('filename');
T = projective2d([0.89 1.24 0.002;
-0.95 1 0.0025;
0 0 1]);
I2 = imwarp(I1(400:800,400:800),T);
0 个评论
回答(1 个)
yanqi liu
2021-9-29
sir,please check the follow code to get some information,same as vl_feat
clc; clear all; close all;
I = imread('cameraman.tif');
I=imresize(I, [1e3 1e3], 'bilinear');
T = projective2d([0.89 1.24 0.002;
-0.95 1 0.0025;
0 0 1]);
J = imwarp(I(400:800,400:800),T);
% Reading the reference Image
C=J;
boxImage = C;
figure; imshow(boxImage);
title('Image of a Box');
%Reading the target image
II = I;
CC=II;
sceneImage = CC;
figure;
imshow(sceneImage);
title('Image of a Cluttered Scene');
%Detect feature images
boxPoints = detectSURFFeatures(boxImage);
scenePoints = detectSURFFeatures(sceneImage);
%Visualize the strongest feature points found in the reference image.
figure;
imshow(boxImage);
title('100 Strongest Feature Points from Box Image');
hold on;
plot(boxPoints.selectStrongest(100));
%Visualize the strongest feature points found in the target image.
figure;
imshow(sceneImage);
title('300 Strongest Feature Points from Scene Image');
hold on;
plot(scenePoints.selectStrongest(300));
%Extract feature descriptors at the interest points in both images.
[boxFeatures, boxPoints] = extractFeatures(boxImage, boxPoints);
[sceneFeatures, scenePoints] = extractFeatures(sceneImage, scenePoints);
%Match the features using their descriptors.
boxPairs = matchFeatures(boxFeatures, sceneFeatures);
%Display putatively matched features.
matchedBoxPoints = boxPoints(boxPairs(:, 1), :);
matchedScenePoints = scenePoints(boxPairs(:, 2), :);
figure;
title('Putatively Matched Points (Including Outliers)');
%This is line 46 where the compiler is indicating an error*
showMatchedFeatures(boxImage, sceneImage, matchedBoxPoints,...
matchedScenePoints,'montage');
%estimateGeometricTransform calculates the transformation relating the matched points,
%while eliminating outliers. This transformation allows us to localize the object in the scene.
[tform, inlierBoxPoints, inlierScenePoints] = estimateGeometricTransform(matchedBoxPoints, ...
matchedScenePoints, 'affine');
%Display the matching point pairs with the outliers removed
figure;
showMatchedFeatures(boxImage, sceneImage, inlierBoxPoints,...
inlierScenePoints, 'montage');
title('Matched Points (Inliers Only)');
%Get the bounding polygon of the reference image.
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();
imshow(sceneImage);
hold on;
line(newBoxPolygon(:, 1), newBoxPolygon(:, 2), 'Color', 'y');
title('Detected Box');
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Feature Detection and Extraction 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!