필터 지우기
필터 지우기

Comparing two binary images

조회 수: 15 (최근 30일)
Elie
Elie 2014년 2월 5일
댓글: Elie 2014년 2월 6일
Hello i'm trying to build a matlab function which is capable of locating the location of an image inside another one : as in the picture
the picture to the right doesn't have the same size as that in the one to the left i tried various method like subtracting the two image , the objective of this is to extract a number which is located beside this tree for that i want to locate the treee then extract the number using ocr , im not experienced in image processing i hope you guide me to the right track. Regards

채택된 답변

Elvin
Elvin 2014년 2월 5일
  댓글 수: 3
Elie
Elie 2014년 2월 6일
편집: Elie 2014년 2월 6일
I'm facing some difficulties in the code, i followed the link you supplied me with and its exactly what i want; But when i try to compile the code im getting an error at a certain part of the code. Everything goes well until the function reaches a certain point and i get this error " Error in Compare (line 46) showMatchedFeatures(boxImage, sceneImage, matchedBoxPoints,matchedScenePoints,'montage') ; " Compare is the name of the function.
Here's the full code
if true
if true
function [ Image] = Compare( Img )
% Reading the reference Image
I= imread('C:\Users\user\Desktop\Matlab-Comparsion\tree11.jpg');
C=rgb2gray(I);
boxImage = C;
figure; imshow(boxImage);
title('Image of a Box');
%Reading the target image
II= imread('C:\Users\user\Desktop\Matlab-Comparsion\4.jpg');
CC=rgb2gray(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;
%This is line 46 of the code where the compiler is indicating the error
showMatchedFeatures(boxImage, sceneImage, matchedBoxPoints,matchedScenePoints,'montage');
title('Putatively Matched Points (Including Outliers)');
%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');
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');
end
end
%Display the matching point pairs with the outliers removed
figure;
% code
end
Please help me , i really appreciate your help.
Elie
Elie 2014년 2월 6일
is there any possibility that this error has to do with my matlab version i have R2012A.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Image Analyst
Image Analyst 2014년 2월 6일
There is SIFT - Scale Invariant Feature Transform, but that's been patented so you can use an similar alternate: SURF. The authors also patented SURF or something related to it, but the good news is that it's built into the Computer Vision System Toolbox. The bad news is that it's pretty challenging to use for novices like you. Good luck.
  댓글 수: 1
Elie
Elie 2014년 2월 6일
Thank you !!!

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Feature Detection and Extraction에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by