demo3
Contents
initialize
clear rgb = imread('birds1.jpg'); % rgb = im2double(rgb); do_input = false; if ~do_input load demo3; end imshow(rgb);

select pixel values
if do_input [c r p] = impixel(rgb); else p = impixel(rgb,c,r); end disp(p),
34 134 0 248 47 1 18 32 103 130 208 8
show pixel locations
imshow(rgb); hold on plot(c,r,'wo'); for n=1:length(c) text(c(n)+10,r(n),sprintf('%d',n),'Color','w'); end hold off % publishes as black plot annotations - runs as white

instantiate distance tool
figure imshow(rgb); if do_input hd = imdistline; %save demo3 c r p point1 point2 else hd = imdistline(gca, pts(:,1), pts(:,2)); end

The Distance tool contains a structure of function handles, called an API, that can be used to retrieve distance information and control other aspects of Distance tool behavior.
api = iptgetapi(hd); w = api.getDistance(); fprintf('distance %g pixels\n',w); pts = api.getPosition(); if do_input save demo3 c r p pts end
distance 177.341 pixels