% example: an example of using ncuts for image segmentation % No attempt is made to optimize the parameters % You can modify them to see the effects on segmentation. % % Stella X. Yu, July 11 2003. % First compile the c files. This only needs to be run once. % You can comment out the following after the compilation. fn = dir('*.c'); for k=1:length(fn), mex('-O',fn(k).name); end % Read in image and turn it into an intensity one imfn = '135069.jpg'; I = double(rgb2gray(imread(imfn))); i = min(I(:)); j = max(I(:)); I = (I-i)/(j-i); % Four settings for image segmentation mask = ones(size(I)); mask(11:end-10,11:end-10) = 0; et = zeros(1,4); for id=1:4, par = imncut; par.reg = 1; switch id, case 1, % attraction case 2, % repulsion par.rep = 0.05; case 3, % attraction + bias par.mask = mask; case 4, % repulsion + bias par.rep = 0.05; par.mask = mask; end tic; imncut(I,par); et(id) = toc; end et