This example shows how to create a simple app that provides information about pixels and features in an image using modular pixel information tools. Because the standard figure window zoom tools are not compatible with the toolbox modular tools, the example suppresses the toolbar and menu bar in the figure window.
Create a function that accepts an image as an argument and displays the image in a figure window with a Pixel Information tool, Display Range tool, Distance tool, and Pixel Region tool.
function my_pixinfotool(im) % Create figure, setting up properties fig = figure('Toolbar','none',... 'Menubar', 'none',... 'Name','My Pixel Info Tool',... 'NumberTitle','off',... 'IntegerHandle','off'); % Create axes and reposition the axes % to accommodate the Pixel Region tool panel ax = axes('Units','normalized',... 'Position',[0 .5 1 .5]); % Display image in the axes img = imshow(im); % Add Distance tool, specifying axes as parent distool = imdistline(ax); % Add Pixel Information tool, specifying image as parent pixinfo = impixelinfo(img); % Add Display Range tool, specifying image as parent drange = imdisplayrange(img); % Add Pixel Region tool panel, specifying figure as parent % and image as target pixreg = impixelregionpanel(fig,img); % Reposition the Pixel Region tool to fit in the figure % window, leaving room for the Pixel Information and % Display Range tools. set(pixreg, 'units','normalized','position',[0 .08 1 .4])
Read an image into the workspace.
pout = imread('pout.tif');
Use the app to display the image with pixel information tools. The tool opens a figure window, displaying the image in the upper half, with the Distance tool overlaid on the image, and the Pixel Information tool, Display Range tool, and the Pixel Region tool panel in the lower half of the figure.