[imagePoints, boardSize, imagesUsed] = detectCheckerboardPoints(imageFileNames); for i = 1:numel(imagesUsed) if imagesUsed(i) fprintf('Image %d: \n', i); disp(imagePoints(:,:,i)); img = imread(imageFileNames{i}); imshow(img); hold on; plot(imagePoints(:,1,i), imagePoints(:,2,i), 'ro', 'MarkerSize', 10); hold off; drawnow; waitforbuttonpress; else fprintf('Image %d: Not used\n', i); end end 修改此代码 用SIFT角点提取算法 提取图片上的角点
时间: 2024-01-28 17:04:06 浏览: 21
使用SIFT角点提取算法提取图片上的角点的代码如下所示:
```
% Load images
imageFileNames = {'01.bmp', '02.bmp', '03.bmp', ... '04.bmp', '05.bmp', '06.bmp', '07.bmp', ... '08.bmp', '09.bmp', '10.bmp'};
% Detect checkerboard points using SIFT algorithm
imagePoints = zeros(0, 2, length(imageFileNames));
for i = 1:length(imageFileNames)
img = imread(imageFileNames{i});
grayImg = rgb2gray(img);
points = detectSURFFeatures(grayImg);
[features, validPoints] = extractFeatures(grayImg, points);
imagePoints(:,:,i) = validPoints.Location;
end
% Display detected points on images
for i = 1:length(imageFileNames)
fprintf('Image %d: \n', i);
disp(imagePoints(:,:,i));
img = imread(imageFileNames{i});
imshow(img);
hold on;
plot(imagePoints(:,1,i), imagePoints(:,2,i), 'ro', 'MarkerSize', 10);
hold off;
drawnow;
waitforbuttonpress;
end
```
在这个代码中,我们使用了MATLAB中的`detectSURFFeatures`和`extractFeatures`函数来提取SIFT角点。这些函数将图像转换为灰度图像,然后在灰度图像上检测SIFT角点,并提取特征描述符。最后,我们使用`validPoints.Location`来提取检测到的角点的坐标,并将它们存储在`imagePoints`中。然后,我们使用`imshow`和`plot`函数来在图像上显示检测到的角点。
请注意,使用SIFT算法可能比使用检测棋盘格角点的默认算法更耗时。如果您的数据集较大,可能需要更长的时间来提取角点。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)