Code covered by the BSD License  

Highlights from
Hysteresis Thresholding

5.0

5.0 | 3 ratings Rate this file 34 Downloads (last 30 days) File Size: 2.13 KB File ID: #20009

Hysteresis Thresholding

by Massimo Fierro

 

22 May 2008 (Updated 27 May 2008)

C implementation of Hysteresis Thresholding

| Watch this File

File Information
Description

This function takes as parameters a grayscale image (real valued matrix of size x*w*1) and two thresholds (low and high), and returns the hysteresis thresholded version.

Hysteresis thresholding performs the following:
- every value below tLo is set to 0
- every value above tHi is set to 1
- the rest of the pixels are set to 1 if they are 4-way connected to any other 1-valued blob (area), 0 otherwise

It should be pretty straightforward to implement an 8-way connection check, if you want.

To compile and use perform the following:
mex hysteresis.c

MATLAB release MATLAB 6.5 (R13)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (4)
30 Jun 2008 hamid afshang  
01 Aug 2010 Priyanshu Agarwal

Hi when I compiled and executed this code, I got the following error. I invoked it as TI = hysthresh(GI,0.1,0.4), where GI is a grayscale image.

??? Error using ==> hysthresh
YPRIME requires that Y be a 4 x 1 vector.

I also tried commenting this part in the code and recompiling the code. However, it ran out of memory.

27 Sep 2010 Gregory

@priyanshu
make sure grayscale image is of type double

22 May 2012 Denis

There seems to be only 1 set of forward-backward propagation set. It'd be nice if the code was extended to do recursively until nothing changes anymore as suggested on http://users.ecs.soton.ac.uk/msn/book/new_demo/thresholding/

I guess its really just putting the propagation part in a while loop with checking if any pixel switched from 0 to 1.

Great function otherwise!

Please login to add a comment or rating.
Updates
27 May 2008

Corrected a type in the title

Tag Activity for this File
Tag Applied By Date/Time
morphology Massimo Fierro 22 Oct 2008 10:02:48
segmentation Massimo Fierro 22 Oct 2008 10:02:48
hysteresis threshold Massimo Fierro 22 Oct 2008 10:02:48
c implementation Massimo Fierro 22 Oct 2008 10:02:48
grayscale Massimo Fierro 22 Oct 2008 10:02:48
image Massimo Fierro 22 Oct 2008 10:02:48
thresholds Massimo Fierro 22 Oct 2008 10:02:48

Contact us at files@mathworks.com