ThresholdLocally
by Brett Shoelson
17 Dec 2010
(Updated 08 Feb 2011)
Performs LOCAL Otsu thresholding on an image, with a user-specified blocksize.
|
Watch this File
|
| File Information |
| Description |
Performs LOCAL Otsu thresholding on an image; user can specify blocksize. Facilitates the threshold-segmentation of images with uneven illumination, without the need for background normalization.
SYNTAX: B = thresholdLocally(A,blksz,varargin)
THRESHOLDLOCALLY processes an image, calling graythresh on LOCAL blocks in an image. This facilitates easy thresholding of images with uneven background illumination, for which global thresholding is inadequate. Uses the Image Processing Toolbox function BLOCKPROC (R2009b).
INPUTS:
A: Any image (or path/name of an image) suitable for processing with im2bw()
BLKSZ: (Optional) Block size of A, for determination of Otsu thresholding using graythresh(). In the form or [M,N]. Default is as determined by BESTBLK.
OPTIONAL:
1) Any P-V pair accepted by BLOCKPROC.
2) FudgeFactor: a scalar value by which to multiply the local value returned by graythresh.
OUTPUT:
B: Output image
EXAMPLE:
img = imread('rice.png');
thresholded = thresholdLocally(img); |
| Acknowledgements |
This file inspired
Segment Tool: An Interactive Gui For Segmenting Images.
|
| Required Products |
Image Processing Toolbox
|
| MATLAB release |
MATLAB 7.11 (R2010b)
|
| Other requirements |
Requires Image Processing Toolbox, R2009b or later. |
|
Tags for This File
|
| Everyone's Tags |
|
| Tags I've Applied |
|
| Add New Tags |
Please login to tag files.
|
| Updates |
| 03 Jan 2011 |
Modified significantly to accept as optional inputs all parameter-value pairs accepted by BLOCKPROC, as well as an additional "fudge factor" parameter that allows one to scale the local graythresh value by a scalar multiple. |
| 11 Jan 2011 |
Fixed problem with screenshot. (Image was inappropriately rotated.) |
| 08 Feb 2011 |
Minor change to replace default blocksize of [32 32] by that returned by function BESTBLK. |
|
Contact us