How to remove/eliminate the background outside the red boundingbox in the picture below?i just need inside the red boundingbox only.
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
boxPoints = detectSURFFeatures(boxImage1); scenePoints = detectSURFFeatures(sceneImage1);
hold on; plot(selectStrongest(scenePoints, 300));
%% Step 3: Extract Feature Descriptors % Extract feature descriptors at the interest points in both images.
[boxFeatures, boxPoints] = extractFeatures(boxImage1, boxPoints); [sceneFeatures, scenePoints ] = extractFeatures(sceneImage1, 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(8); showMatchedFeatures(boxImage1, sceneImage1, matchedBoxPoints, matchedScenePoints, 'montage'); legend('matched Boxpoints 1','matched Scenepoints 2'); 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, 'similarity'); %figure(9);
% Display the matching point pairs with the outliers removed
showMatchedFeatures(boxImage1, sceneImage1, inlierBoxPoints, inlierScenePoints, 'montage'); title('Matched Points (Inliers Only)');
% Get the bounding polygon of the reference image.
boxPolygon = [1, 1;... % top-left size(boxImage1, 2), 1;... % top-right size(boxImage1, 2), size(boxImage1, 1);... % bottom-right 1, size(boxImage1, 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(10); imshow(sceneImage1); hold on; line(newBoxPolygon(:, 1), newBoxPolygon(:, 2), 'Color', 'r'); title('Detected Box');
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/147443/image.png)
0 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu Feature Detection and Extraction finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!