Code covered by the BSD License  

Highlights from
Thresholding an image

4.66667

4.7 | 3 ratings Rate this file 137 Downloads (last 30 days) File Size: 28.8 KB File ID: #29372
image thumbnail

Thresholding an image

by

 

GUI with sliders to set a threshold range on an image. Make a binary image.

| Watch this File

File Information
Description

This program takes a color or monochrome image and lets the user threshold the monochrome image, or a single color band of a color image, via sliders to set the maximum and minimum thresholds. The pixels in the thresholded range are shown in the middle image as a binary image (black/white), and the original image pixels are shown masked in the left image (gray scale or color). Inputs are the low and high thresholds to start with and the image filename or image matrix. The program returns the threshold values and the last color band that was used to select the threshold. The image can be of type integer (uint8, uint16, etc.) or floating point (single, double).

Required Products Image Processing Toolbox
MATLAB release MATLAB 7.11 (R2010b)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (6)
21 Dec 2013 Usama Farooq

good...

09 Sep 2013 Amit Nambiar

Thank you for this wonderful tutorial. It really helped me a lot to understand the concept of thresholding in detail and also the matlab codes are wonderful.

Thanks a lot Sir!

28 Jul 2011 Bryson

Sorry, Sean de, do you mind mentioning how to fix this issue. Which Set(..) in threshold.m should I turn off ?

12 Nov 2010 Sean de

I have 2009b and the 'monitorpositions' option is available.

I found that in the demo_script leaving the set(..) the way you have it works fine and then turning off the set in threshold.m makes it a perfect size. It was this way before too, I could see the figure load set up and look good, then expand to be multiple times my screen width on that call to set().

Anyway, excellent demo! Definitely useful for beginners to understand thresholding.

12 Nov 2010 Image Analyst

Sean, I got to admit I didn't test it on a system with two monitors. The MonitorsPosition seems to be new with R2010b (at least they call it "new" in the 2010b help) so if I put that in it won't work for anyone with older versions. I had considered the Mathworks recommended "maxfig" but I wanted this to be standalone and not require any other code to be downloaded. If you have a fix that will work with all versions, I'd like to see it, and may build it in.

12 Nov 2010 Sean de

The call to:
set(gcf, 'Position', get(0,'Screensize')); % Enlarge figure to full screen.

Blows the figure up on to the point of being way too big to do anything on dual monitors since the screen size is returned as the size of both. The root property 'MonitorPositions' has the individual sizes of the primary and secondary monitors.

Contact us