Effacer les filtres
Effacer les filtres

what is wrong here?please.

2 vues (au cours des 30 derniers jours)
mmm ssss
mmm ssss le 16 Fév 2012
Modifié(e) : Jan le 24 Oct 2013
Hi All
i need to do matching between 2 images in matlab by following these steps:
1.Input: P1, P2 (two images).
2.Variables: Current-Matching-Ratio, Maximum-Matching-Ratio.
3.1 From: rotation = - theta; To: rotation= + theta; Step = 10 Apply rotation on P2.
3.2 From: y-translation = - ty; To: y-translation= + ty; Step = 10 Apply y-translation on P2.
3.3 From: x-translation = - tx; To: x-translation= + tx; Step = 10 Apply x-translation on P2.
3.4 Calculate Current-Matching-Ratio (the matching ratio between P1 and transformed P2)[which is no. of the overlapped white pixels between P1 and transformed P2 /no. of the white pixels in one of 2 ip image (preferably the image with the minimum count of the white pixels)].
3.5 If Current-Matching-Ratio > Maximum-Matching-Ratio Then
Maximum-Matching-Ratio = Current-Matching-Ratio Matching-Angle = rotation Matching-Y-Translation = y-translation Matching-X-Translation = x-translation
when i tried to perform this , i wrote:
tic
p0 = imread...........;
p1 = imread...........;
max_match_ratio=0;
if (nnz(p0)>nnz(p1))because i prefer to perform transformation on the image with smaller number of white pixels
p2=p1;
else
p2=p0;
end
for q=-150:10:150;
for tx=-50:10:50;
for ty=-50:10:50;
xform=[cos(q) sin(q) 0 ;-sin(q) cos(q) 0;tx ty 1];
t_form_rotate_translate=maketform('affine',xform);
cb_trans=imtransform(p2,t_form_rotate_translate);
current_matching=(sum(p2(:))&sum(cb_trans(:)))/sum(p2(:));
if (current_matching>max_match_ratio)
max_match_ratio=current_matching;
match_angle=q;
match_x_trans=tx;
match_y_trans=ty;
end
end
end
end;
time=toc;
when i implement this code ,i obtained max_match_ratio= 0.000957854406130268
i know that these images are very similar to each other ?so why this bad result ? what are the error that i did ?
help me please?
thanks

Réponses (1)

Image Analyst
Image Analyst le 17 Fév 2012
Can you give code to generate p0 and p1 from standard MATLAB demo images? Something like this:
folder = fullfile(matlabroot, '\toolbox\images\imdemos');
baseFileName = 'cameraman.tif';
fullFileName = fullfile(folder, baseFileName);
% Get the full filename, with path prepended.
fullFileName = fullfile(folder, baseFileName);
if ~exist(fullFileName, 'file')
% Didn't find it there. Check the search path for it.
fullFileName = baseFileName; % No path this time.
if ~exist(fullFileName, 'file')
% Still didn't find it. Alert user.
errorMessage = sprintf('Error: %s does not exist.', fullFileName);
uiwait(warndlg(errorMessage));
return;
end
end
grayImage = imread(fullFileName);
p0 = grayImage < 80;
Then we can try your code. Or else upload your exact binary images to tinypic.com.
Now, your algorithm looks extremely naive. Who gave you this algorithm, where did you see it, or did you think it up yourself? Finding if a binary image is a rotated and translated version of your reference image via this method of ANDing the images and counting the overlapping pixels is not robust or reliable, and has no specificity. If you're trying to do that, you should pick a different method (like one that will work - perhaps SURF).
  12 commentaires
mmm ssss
mmm ssss le 20 Fév 2012
thanks in advance.this is a new information, i don't know it before.
i will use instead of sin() and cos()
mmm ssss
mmm ssss le 24 Fév 2012
hello all, i need only to inform you about this algorithm , it is not work on my images ,because of skeletonization which will affect the number of overlapped pixels and this will reduce the similarity.thank you very much to Image Analyst ,Walter Roberson.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Geometric Transformation and Image Registration dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by