aoi1

im = imread('ic.jpg');
imshow(im);

impixelinfo creates a Pixel Information tool in the current figure. The Pixel Information tool displays information about the pixel in an image that the pointer is positioned over.

impixelinfo;

h = imdistline creates a Distance tool on the current axes. The Distance tool is a draggable, resizable line, superimposed on an axes, that measures the distance between the two endpoints of the line.

imshow(im)
hd = imdistline;

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);