File Exchange

image thumbnail

Soft thresholding for image segmentation

Image segmentation based on histogram soft thresholding


Updated 09 Jun 2015

View License

FTH is a fuzzy thresholding method for image segmentation. The method is based on relating each pixel in the image to the different regions via a membership function, rather than through hard decisions. The membership function of each of the regions is derived from a fuzzy c-means centroid search. As a consequence, each pixel will belong to different regions with a different level of membership. This feature is exploited through spatial processing to make the thresholding robust to noisy environments.
Method proposed in:
Aja-Fernández, S., A. Hernán Curiale, and G. Vegas-Sánchez-Ferrero, "A local fuzzy thresholding methodology for multiregion image segmentation", Knowledge-Based Systems, vol. 83, pp. 1-12, 07/2015.
DOI 10.1016/j.knosys.2015.02.029

This new version is highly improved.

New Version, 4.0

Comments and Ratings (20)

Samar Ragab

I have this error : MG=fth(I,0,2,1,0.02);
Error using smooth (line 73)
SMOOTH needs at least one argument.

Error in maxima_search (line 27)
sig = smooth.*[1 1 1]; % 1.5 in each dimension

would you please tell me how you show the threshold image after running the code?

Peps Reynoso

Hello, Santiago. This code is helping me immensely. I'm still trying to understand the code and paper, but I wanted to thank you for sharing this.


DaDu (view profile)


Martin (view profile)

Answer to Arnold: Your output will strongly depend on the input image. COntact me by mail and I can check where it is failing.


arnold (view profile)

doesn't work for me. Gives 'S' and 'MG' which contains just ones.

Kindly tell me the steps to follow run this code

Xidian NO.1


thank u for sharing

Dear Sir..
Thanx alot about sharing... I can not run it because of this error:

??? Error using ==> shiftmat
Too many input arguments.

Error in ==> seg_fuzzy at 207
M_tmp = shiftmat(Mx,i,1);

can you explain us how to implement it..
with my Regards...


Edwin (view profile)

Thanks for your sharing. would you please tell me how you show the threshold image after running the code?

Thanks for your help in advanced!

Thank you so much for your sharing code, it is very impressive.
I've read your paper and I would like to ask about the median MG (step 6). I confuse the use of MG and about calculating the MX in step 5 and step 6, since in your code, you didn't do anything about MG.
Thank you very much for your kind response.

Modify anything you want, of course. It should be easy. I cannot say when next version will be ready, sorry. I'll try to do it along these months.


leila (view profile)

thank you. I want to try it on 3d US images, can I change it? when the next version will be written?

The function is a basic implementation thought for 2D, but with very small changes it could work for 3D. The square neighborhoods used for smoothing and aggregation must be replaced by 3D neighborhoods. (I'll do it for the next version...)


leila (view profile)

does the function support 3d images?

The original file lacks of a control for more than 5 output sets. New version with problem corrected is added.


Sven (view profile)

Your example itself fails with an error:

>> [S,MG,Nmax]=seg_fuzzy(I,1,2)

Undefined function or variable "Mx".

Error in seg_fuzzy (line 196)


Reference to the published paper added.

- The centroids are now searched by a fuzzy c-means.
- 5 different spatial aggregations are considered.
- The optimization step has been avoided.
- A threshold to prune output sets has been added.

Small change to correct a bug in 3D

A bug in shiftmat is corrected

Version 3: It admits 3D data and rgb images. It has no limit of number of output sets. Some minor bugs were corrected

Bug corrected for more than 5 maxima in smoothed histogram

MATLAB Release Compatibility
Created with R14
Compatible with any release
Platform Compatibility
Windows macOS Linux

Inspired by: elmat+ 2.2

Discover Live Editor

Create scripts with code, output, and formatted text in a single executable document.

Learn About Live Editor