I'm trying to track marks in a mouse leg using imfindcircles
. It works great for the first image, but the others are a mess even though they are very similar. This is the incorrect output. What is wrong with my code?
%Array
A = [0 0;0 0;0 0;0 0];
%multiarray to keep the coordinates
multA(:,:,7) = [0 0;0 0;0 0;0 0];
for k = 1:7
% Create an image filename, and read it in to a variable called imageData.
bmpFileName = strcat('image', num2str(k), '.bmp');
if exist(bmpFileName, 'file')
imageData = imread(bmpFileName);
bmpFileName= imcrop(imageData,[1350 150 300 250]);
[centers, radii] = imfindcircles( bmpFileName,[4 8],'ObjectPolarity','dark', 'Sensitivity', 0.9,'EdgeThreshold',0.05);
figure(1)
imshow(bmpFileName)
viscircles(centers,radii)
multA(:,:,k)=[centers(1,1) centers(1,2);centers(2,1) centers(2,2); centers(3,1) centers(3,2);centers(4,1) centers(4,2)];
pause(0.5)
else
fprintf('File %s does not exist.\n', bmpFileName);
end
end