Code covered by the BSD License  

Highlights from
Thresholding an image

5.0

5.0 | 1 rating Rate this file 87 Downloads (last 30 days) File Size: 28.82 KB File ID: #29372
image thumbnail

Thresholding an image

by Image Analyst

 

12 Nov 2010

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 (2010b)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (4)
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.

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

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.

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 ?

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
image processing Image Analyst 12 Nov 2010 13:09:55
threshold Image Analyst 12 Nov 2010 13:09:55
binarize Image Analyst 12 Nov 2010 13:09:55
binary image Image Analyst 12 Nov 2010 13:09:55
binary image Fits 14 May 2011 08:23:08
binarize Pedro Tovar 10 Oct 2011 20:41:16
binarize Grigory 18 Dec 2011 07:42:36

Contact us at files@mathworks.com