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).
1. Good layout.
2. GUI does exactly what it claims to do.
3. Almost unbelievable - here is an example of well-commented code. I find the lack of good commenting in code appalling these days. To all programmers: comment your code - it will help you or another user use it down the track, and will often help you structure your code logically when composing it in the first place!
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.
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.
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.