مرحله اول : خواندن تصویر هدف و تصویری اولیه (تصویری که قرار است هدف ما در آن شناسایی و جداسازی گردد.)
تصویرهدف
;(boxImage = imread('stapleRemover.jpg'
تصویر اولیه
;(sceneImage = imread('clutteredDesk.jpg'
مرحله دوم:تشخیص نقاط ویژگی در هر دو تصویر اولیه و هدف:
;(boxPoints = detectSURFFeatures(boxImage
;(scenePoints = detectSURFFeatures(sceneImage
مرحله سوم: استخراج توصیفگرهای ویژگی در نقاط مورد علاقه در هر دو تصویر.
;([boxFeatures, boxPoints] = extractFeatures(boxImage, boxPoints
;([sceneFeatures, scenePoints] = extractFeatures(sceneImage, scenePoints
مرحله چهارم: مطابقت ویژگی های تصاویر با یکدیگر با استفاده از توصیفگرهایشان.
;(boxPairs = matchFeatures(boxFeatures, sceneFeatures
نمایش ویژگی های منطبق شده:
;(:,matchedBoxPoints = boxPoints(boxPairs(:, 1)
;(:,matchedScenePoints = scenePoints(boxPairs(:, 2)
;figure
showMatchedFeatures(boxImage, sceneImage, matchedBoxPoints, ...
;( matchedScenePoints, 'montage'
;(title('Putatively Matched Points (Including Outliers)'
مرحله پنجم:پیدا کردن هدف در تصویر اولیه با توجه به نتایج به دست آمده
[tform, inlierBoxPoints, inlierScenePoints] = ...
;(estimateGeometricTransform(matchedBoxPoints, matchedScenePoints, 'affine'
;figure
...,showMatchedFeatures(boxImage, sceneImage, inlierBoxPoints
;('inlierScenePoints, 'montage
;('(title('Matched Points (Inliers Only)