manual_thresh interactively select intensity levels band for image thresholding.
The code is based on thresh_tool by Robert Bemis found in MATLAB CENTRAL (can be considered as an improved version of it) but it has some more features:
1. The possibility to choose a band of intensities rather than only the low threshold level.
2. Editable texts and sliders were added to facilitate the use.
3. The segmented image is displayed as a layer on the top of the original image which makes it easy to decide which pixels intensities have to be chosen.
manual_thresh launches a GUI (graphical user interface) for thresholding an intensity input image, IM. IM is displayed in the top of the figure . A colorbar and IM's histogram are displayed on the bottom. Vertical lines on the histogram indicates the current threshold levels. The segmented image
(with the intensity levels between the low and high threshold levels is displayed as a upper layer with transparent background on the top of the original image. To change the level, click and drag the lines or use the editable text or sliders. The output image updates automatically.
There are two ways to use this tool.
Mode 1 - nonblocking behavior:
manual_thresh (IM) launches GUI tool. You can continue using the MATLAB
Desktop. Since no results are needed, the function does not block
execution of other commands.
manual_thresh (IM,CMAP) allows the user to specify the colormap, CMAP. If not specified, the default colormap is used.
manual_thresh (IM,CMAP,DEFAULTLEVEL) allows the user to specify the default low threshold level. If not specified, DEFAULTLEVEL is determined by GRAYTHRESH. Valid values for DEFAULTLEVEL must be consistent with the data type of IM for integer intensity images: uint8 [0,255], uint16 [0,65535], int16 [-32768,32767].
x = imread('coins.png');
manual_thresh(x) %no return value, so MATLAB keeps running
Mode 2 - blocking behavior:
[LOW LEVEL, HIGH LEVEL] = manual_thresh (...) returns the user selected levels, LOW LEVEL $ HIGH LEVEL, and
MATLAB waits for the result before proceeding. This blocking behavior
mode allows the tool to be inserted into an image processing algorithm
to support an automated workflow.
[LOW LEVEL, HIGH LEVEL,BW] = manual_thresh(...) also returns the thresholded binary
output image, BW.
x = imread('coins.png');
[LOW LEVEL, HIGH LEVEL] = manual_thresh(x') %MATLAB waits for GUI tool to finish
yist Tauber (2021). Manual Thresholding Tool (https://www.mathworks.com/matlabcentral/fileexchange/28723-manual-thresholding-tool), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform CompatibilityWindows macOS Linux
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!