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

조회 수: 6 (최근 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에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by