Image Processing Toolbox User's Guide |
Example: Building a Pixel Information GUI
This example shows how to use the tools to create a simple GUI. If your work typically requires information about the pixels in an image, you might want to create a custom image display function that provides this information. You can do this by using the three modular tools that provide pixel information:
This example creates a simple image display function that includes these tools. In this GUI, the Pixel Region tool is embedded in the same figure window as the target image. The example suppresses the figure window toolbar and menu bar, because the standard figure zoom tools are not compatible with the toolbox modular navigation tools -- see Adding Navigation Aids to a GUI.
function my_pixinfotool(im) % Create figure, setting up properties hfig = figure('Toolbar','none',... 'Menubar', 'none',... 'Name','My Pixel Info Tool',... 'NumberTitle','off',... 'IntegerHandle','off'); % Create axes % Reposition the image to accommodate the Pixel Region tool hax = axes('Units','normalized',... 'Position',[0 .5 1 .5]); % Display image, getting handle to image himage = imshow(im); % Add Pixel Information tool to image figure window hpixinfo = impixelinfo(himage); % Add Display Range tool to image figure window hdrange = imdisplayrange(himage); % Add Pixel Region tool as panel in same figure hpixreg = impixelregionpanel(hfig,himage); % Reposition the Pixel Region tool to fit in the figure % window, leaving room for the Pixel Information and % Display Range tools. set(hpixreg, 'units','normalized','position',[0 .08 1 .4])
To use the tool, pass it an image that is already in the MATLAB workspace.
The tool opens a figure window, displaying the image in the upper half and the three pixel information modular tools, the Pixel Information tool, Display Range tool, and the Pixel Region tool, in the lower half.
Custom Image Display Tool with Pixel Information
Positioning the Modular Tools in a GUI | Adding Navigation Aids to a GUI |
© 1994-2005 The MathWorks, Inc.