%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function modify( path ) % output_image = modify( input_image , raw_image ) % input_image : bw image of centers % raw_image : raw image so that user can more easily located where centers % should be % output_image : bw image of centers after user has modified them % % method: user LEFT clicks to create a center % user RIGHT click to remove a center, users findnearest to remove % nearest center % user CENTER clicks to exit load('-mat', path, 'x','y','N', 'xmax', 'ymax', 'rotim', 'conn'); figure(1) imagesc(rotim) hold on plot( x, y, 'b+'); hold off colormap gray truesize title 'LEFT click = create center, RIGHT click = remove center, CENTER to end or pause ' disp( 'to zoom or pan, first pause, then adjust while paused') cont = 'y'; while cont ~= 'q' figure(1) [xxx,yyy,button] = ginput(1); xxx = round(xxx); yyy = round(yyy); % check for out of bounds if( xxx<0 | yyy<0 | xxx> xmax | yyy > ymax) break; end if button == 1 % create a center x = [x;xxx]; y = [y;yyy]; conn = [conn;0,0,0,0,0,0]; N = N+1; hold on plot(xxx,yyy,'g+') hold off elseif button == 3 % remove a center n = findclosest(x,y, xxx,yyy ); hold on plot(x(n),y(n),'ro') hold off y(n) = []; x(n) = []; for a = 1:6 if conn(n,a) ~= 0 conn(conn(n,a), mod(a+2,6)+1) = 0; end end conn(n, :) = []; % trickle down effect (now all numbers > n are wrong temp = []; for a = 1: numel(conn(:)) if conn(a) > n conn(a) = conn(a) - 1; end end N = N-1; else cont = input( '[p]ause [q]uit: ','s'); if cont ~= 'q' pause; end end end close(1) save(path, 'x','y', 'N','conn', '-mat', '-append');