File Exchange Pick of the Week

April 5th, 2006

Finding the right threshold value

The Image Processing Toolbox, which was introduced over ten years ago, is one of the most popular of The MathWorks’ Toolboxes, reflecting the breadth of industries in which image analysis plays a role. Most of us who have done significant work with the Toolbox over the years can point to numerous instances in which we wanted the ability to manipulate our images interactively, and to see the results of our changes as we made them. Bob Bemis’s thresh_tool provides just such functionality for interactively selecting a threshold level for reducing an image to binary form.

Bob’s code is slick; it automatically generates a histogram of the input image, along with a slider-like interface for moving the threshold level along the histogram axis. As you move the slider line, another axes automatically updates to show the result of thresholding at the selected level. Thresh_tool provides an easy way to use the code with either modal or non-modal behavior, supports user-selected colormaps, and can output both the user-selected level and the binary image it produces.

One of the nicest things about thresh_tool is that it is well-documented, and serves well as a model for the implementation of other interactive tools. Bob is a MATLAB and IPT guru, and I strongly encourage would-be developers to take a look at his implementation of this nice interactive GUI.

Leave a Reply

Wrap code fragments inside <pre> tags, like this:

<pre class="code">
a = magic(3);
sum(a)
</pre>

If you have a "<" character in your code, either follow it with a space or replace it with "&lt;" (including the semicolon).


MathWorks

Brett & Jiro share their favorite user-contributed submissions from the File Exchange.

These postings are the author's and don't necessarily represent the opinions of The MathWorks.