This is a matlab function that i wrote for identifying tound objects.i'm kinda a newbie in image processing so i'm guessing my code is messed up some where.But i don't seem to understand my error.please do help..:)
The code is ::
function [ ] =imagetestfile( im )%This is a fuction to identify round objects from the given input image
im1=rgb2gray(im);thresh=graythresh(im1);im1=im2bw(im1,thresh);[a b]=bwboundaries(im1);info=regionprops(b,'Area','Centroid','Perimeter');i=1;for k=1:length(a) q=(4*pi*info(k).Area)/(info(k).Perimeter)^2; if q>0.80 c{i}=a{k}; info1{i}.Centroid=info{k}.Centroid; i=i+1 ; endendimshow(im);hold onfor k=1:i-1 x=info1(k).Centroid(1); y=info1(k).Centroid(2); boundary = c{k}; plot(boundary(:,2), boundary(:,1), 'w', 'LineWidth', 6); line(x,y, 'Marker', '*', 'MarkerEdgeColor', 'r');endhold offend
Best Answer