1759 1

[Weka及其他] MATLAB课程:代码示例之Image Processing and Computer Vision(五) [推广有奖]

企业贵宾

巨擘

0%

还不是VIP/贵宾

-

威望
4
论坛币
624047 个
通用积分
147.0356
学术水平
918 点
热心指数
988 点
信用等级
842 点
经验
398722 点
帖子
9795
精华
48
在线时间
17322 小时
注册时间
2014-8-19
最后登录
2022-11-2

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币

MATLAB课程:代码示例之Image Processing and Computer Vision(五)


Object Detection in a Cluttered Scene Using Point Feature Matching


This example shows how to detect a particular object in a cluttered scene, given a reference image of the object.


Overview

This example presents an algorithm for detecting a specific object based on finding point correspondences between the reference and the target image. It can detect objects despite a scale change or in-plane rotation. It is also robust to small amount of out-of-plane rotation and occlusion.

This method of object detection works best for objects that exhibit non-repeating texture patterns, which give rise to unique feature matches. This technique is not likely to work well for uniformly-colored objects, or for objects containing repeating patterns. Note that this algorithm is designed for detecting a specific object, for example, the elephant in the reference image, rather than any elephant. For detecting objects of a particular category, such as people or faces, see vision.PeopleDetector and vision.CascadeObjectDetector.

Step 1: Read Images

Read the reference image containing the object of interest.

boxImage = imread('stapleRemover.jpg');figure;imshow(boxImage);title('Image of a Box');


Read the target image containing a cluttered scene.

sceneImage = imread('clutteredDesk.jpg');figure;imshow(sceneImage);title('Image of a Cluttered Scene');


Step 2: Detect Feature Points

Detect feature points in both 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(selectStrongest(boxPoints, 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(selectStrongest(scenePoints, 300));


Step 3: Extract Feature Descriptors

Extract feature descriptors at the interest points in both images.

[boxFeatures, boxPoints] = extractFeatures(boxImage, boxPoints);[sceneFeatures, scenePoints] = extractFeatures(sceneImage, scenePoints);


Step 4: Find Putative Point Matches

Match the features using their descriptors.

boxPairs = matchFeatures(boxFeatures, sceneFeatures);


Display putatively matched features.

matchedBoxPoints = boxPoints(boxPairs(:, 1), :);matchedScenePoints = scenePoints(boxPairs(:, 2), :);figure;showMatchedFeatures(boxImage, sceneImage, matchedBoxPoints, ...    matchedScenePoints, 'montage');title('Putatively Matched Points (Including Outliers)');


Step 5: Locate the Object in the Scene Using Putative Matches

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');


Step 7: Detect Another Object

Detect a second object by using the same steps as before.

Read an image containing the second object of interest.

elephantImage = imread('elephant.jpg');figure;imshow(elephantImage);title('Image of an Elephant');


Detect and visualize feature points.

elephantPoints = detectSURFFeatures(elephantImage);figure;imshow(elephantImage);hold on;plot(selectStrongest(elephantPoints, 100));title('100 Strongest Feature Points from Elephant Image');


Extract feature descriptors.

[elephantFeatures, elephantPoints] = extractFeatures(elephantImage, elephantPoints);


Match Features

elephantPairs = matchFeatures(elephantFeatures, sceneFeatures, 'MaxRatio', 0.9);


Display putatively matched features.

matchedElephantPoints = elephantPoints(elephantPairs(:, 1), :);matchedScenePoints = scenePoints(elephantPairs(:, 2), :);figure;showMatchedFeatures(elephantImage, sceneImage, matchedElephantPoints, ...    matchedScenePoints, 'montage');title('Putatively Matched Points (Including Outliers)');


Estimate Geometric Transformation and Eliminate Outliers

[tform, inlierElephantPoints, inlierScenePoints] = ...    estimateGeometricTransform(matchedElephantPoints, matchedScenePoints, 'affine');figure;showMatchedFeatures(elephantImage, sceneImage, inlierElephantPoints, ...    inlierScenePoints, 'montage');title('Matched Points (Inliers Only)');


Display Both Objects

elephantPolygon = [1, 1;...                                 % top-left        size(elephantImage, 2), 1;...                       % top-right        size(elephantImage, 2), size(elephantImage, 1);...  % bottom-right        1, size(elephantImage, 1);...                       % bottom-left        1,1];                         % top-left again to close the polygonnewElephantPolygon = transformPointsForward(tform, elephantPolygon);figure;imshow(sceneImage);hold on;line(newBoxPolygon(:, 1), newBoxPolygon(:, 2), 'Color', 'y');line(newElephantPolygon(:, 1), newElephantPolygon(:, 2), 'Color', 'g');title('Detected Elephant and Box');




二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:Processing processI Computer MATLAB课程 compute MATLAB课程 代码示例 ImageProcessingandComputerVision ObjectDetectioninaClutteredSceneUsingPointFeatureMatching

本帖被以下文库推荐


https://www.cda.cn/?seo-luntan
高薪就业·数据科学人才·16年教育品牌
沙发
美国队长2 在职认证  发表于 2016-3-14 14:05:17 |只看作者 |坛友微信交流群
哇塞,好厉害的样子,太牛了。。。

使用道具

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-4-28 23:08