Watch this Author's files
Excellent code and helpful comments on test cases. If you don't have IPToolbox or SPToolbox, you can still use this if you create or pick up a third-party version of bwlabel.m (labels blobs of dark/light pixels) and filtfilt.m (fwd/bkwd filter).
Contact us at files@mathworks.com