This program takes a color or monochrome image and lets the user interactively/manually threshold the monochrome image, or a single color band of a color image, via sliders to set the maximum and minimum thresholds. The thresholded image is a binary image that can be used as a mask image for other images. 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 file name 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).
thank you for sharing the codes. I work with Bruker and at the beginning, its a bit different, but i don't succeed and find how can i save the Mask(binary Image) created by the threshold function. B=dir('*.png'); this command is nt enough. i think i have missed a point.
Are you a genius or something?
Hi and thank you very much for sharing this great code. How can I save the binary image?
Hi, can this be used to detect texture and extract it from an image?
example see this image. I am trying to segment the floor area where the cabinets are and keeping the borders
Thanks for this handy tool.
Really awesome code. Image Analyst indeed you are great.....
Tian Tian, you write code and you pass the image into the threshold function as a variable in the input argument list when you call the function from your main program.
Thank you for sharing this excellent program. May I consult you a question? Should I open the window and import my images? How to import image to the window please?
First, congratulations on the excellent program. I would like to insert a zoom button, but when I did this with the Toolbar editor, it did not work, it would be interesting also a zoom sync of the 3 images.
Thank you, this code really helped! Keep up the good work!
how to change the path of image
Dear Image Analyst,
This tool is very impressive. May I know which paper u followed for the implementation of this code. Thank you
Does this work with Matlab R2013a?
Excellent work. Is it possible not to show the GUI and just returning the max and min values?
You should think of preparing a MOOC on image analysis. I will definitely buy it. Thanks..
I see your comments in questions posed by others and always they are very helpful. Voting up your answers.
It works really fine, very helpful. Thank you very much.
I have a question,
How can we can we perform accurate edge detection for grayscale images using adaptive detection schemes? I am not talking to use conventional edge thresholding schemes.
1. How it can perform thresholding to removes noise as well.
2. How it can adaptively threshold for 0-255 at each pixel without converting into binary image?
I want to check the performance on edges in images with lot of details.
Kindly elaborate with example.
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!
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!
Sorry, Sean de, do you mind mentioning how to fix this issue. Which Set(..) in threshold.m should I turn off ?
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.
Fixed bug about typing in a value for a floating point image.
Changed description slightly
Updated to work with R2015a.
Inspired: Parametric Mapping Scripts for MRI data