How to compare two images using information about spots location in the two images?

2 次查看(过去 30 天)
Hi. i am using two images that have spots in them. the two images are similar. some spots in image 1 are not present in image 2 and vice versa. furthermore spots present in both may slightly differ in location (few pixels).i want to find spots that are present in both. for that i am using regionprops PixelList to first detect spots and then compare pixelList if image 2 with that of image 1. If one pixel matches then spot matches. Howerever my codes isn't working properly. it gives all spots presnt in image 2 as output. kindly guide me. my code is as follows. i have also attaced the two images.
function[]=SPOT_MATCHING() % function[]=SPOT_MATCHING(user_Image,template) %
i=imread('modal_breast_A.jpg');
i3=i;
i=rgb2gray(i);
% i=water_s(i); IX=edge(i,'canny');
% [B,L,N] = bwboundaries(IX,'noholes'); cc = bwconncomp(IX, 8);
%CENTROIDS OF OBJECTS s = regionprops(cc, {'Area', 'Centroid','PixelIdxList', 'PixelList'});
% C = regionprops(cc, { 'Centroid'}); A = regionprops(cc, {'Area'});
centroids = [s.Centroid]; x = centroids(1:2:end-1);
y = centroids(2:2:end);
figure,imshow(i); hold on plot(x,y,'*')
%%%%%%%%%%%%%%%%%%% SECOND IMAGE%%%%%%%%%%%%%%%%%%%%% % % z=user_Image; %z=rgb2gray(z); z=imread('modal_breast_B.jpg');
z3=z; z=rgb2gray(z); % BWz=water_s(z);
IXz=edge(z,'canny');
% figure % imshow(IXz)
%[Bz,Lz,Nz] = bwboundaries(IXz,'holes');
ccz = bwconncomp(IXz, 8);
%CENTROIDS OF OBJECTS sz = regionprops(ccz, {'Area', 'Centroid','PixelIdxList', 'PixelList'});
% Cz = regionprops(ccz, { 'Centroid'}); Az = regionprops(ccz, {'Area'}); % length(Cz);
centroidsz = [sz.Centroid];
xz = centroidsz(1:2:end-1); yz = centroidsz(2:2:end);
figure,imshow(z3); hold on plot(xz,yz,'*')
%%%% BRUTE FORCE SEARCH FOR SPOTS%%%%%%%%%%%%%%%%%%%%%%%%%%
figure imshow(z); hold on
totalmatches=0; mismatch=0;
for loop2=1:length(Az) for loop=1:length(A) % found= ismember(s(loop).Centroid,sz(loop2).PixelList);
% % if found~=0 if ismember(1,found)==1 % display('match') plot(xz(loop2),yz(loop2),'square'); % totalmatches=totalmatches+1;
break
%
elseif ismember(1,found)~=1
plot(xz(loop2),yz(loop2),'*','color','g');
mismatch=mismatch+1;
%
continue
end
end
end
disp('total spot in figure 1') length(x)
disp('total spots in figure 2') length(xz)
disp('total matches') totalmatches
disp('total mismatches') mismatch
% % figure % plot([totalmatches;length(centroidsz)])
  1 个评论
Image Analyst
Image Analyst 2015-5-26
Don't double space your code. Single space it. Paste it in then highlight it and click {}Code button. Or else attach the m-file with the paper clip icon.

请先登录,再进行评论。

回答(1 个)

Image Analyst
Image Analyst 2015-5-26
  1 个评论
Sana Tayyeb
Sana Tayyeb 2015-5-26
No i have not. i need to use and work on my code as i have to submit my working code by tomorrow. can you please help me make it better or guide me where i am going wrong.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Images 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by