Image Contour Extraction

Copyright Tristan Aubrey-Jones November 2006.

icetimer.m

home Home   up Up   ( Download )


function times = icetimer(impath, nvalues) %% load image im = imread(impath); imsz = size(im); %% pre-process image img = imedgefilter(im); img = normimg(img); img = imnoisefilter(img); %% init times = zeros(length(nvalues), 2); times(:,1) = nvalues; c = [imsz(1) / 2; imsz(2) / 2]; r = floor(min(imsz(1), imsz(2)) / 2) - 2; %% for all values of n for j = 1:length(nvalues) % construct circular contour with n points n = nvalues(j); con = zeros(n,2); for i = 1:n theta = 2 * pi * i / n; xy = c + r * [cos(theta); sin(theta)]; con(i,:) = round(xy'); end % perform greedy ice using con tot = 0.0; for r = 1:3 t = cputime; greedyice(con, img); tot = tot + (cputime - t); end times(j,2) = tot / 3; %% show result times(j,:) end