File Exchange

image thumbnail

Multilevel Thresholding Segmentation Based on Harmony Search Optimization

version (92.1 KB) by Diego Oliva
An implementation of harmony search algorithm for multilevel thresholding image segmentation


Updated 26 Jun 2014

View Version History

View License

In this paper, a multilevel thresholding (MT) algorithm based on the harmony search algorithm (HSA) is introduced. HSA is an evolutionary method which is inspired in musicians improvising new harmonies while playing. Different to other evolutionary algorithms, HSA exhibits interesting search capabilities still keeping a low computational overhead. The proposed algorithm encodes random samples from a feasible search space inside the image histogram as candidate solutions, whereas their quality is evaluated considering the objective functions that are employed by the Otsu’s or Kapur’s methods. Guided by these objective values, the set of candidate solutions are evolved through the HSA operators until an optimal solution is found. Experimental results demonstrate the high performance of the proposed method for the segmentation of digital images.
****The main file for each method (OTSU or KAPUR) is Mth.HS1.m****
The proposed algorithm was published in:
Diego Oliva, Erik Cuevas, Gonzalo Pajares, Daniel Zaldivar, and Marco Perez-Cisneros, “Multilevel Thresholding Segmentation Based on Harmony Search Optimization,” Journal of Applied Mathematics, vol. 2013, Article ID 575414, 24 pages, 2013. doi:10.1155/2013/575414
Journal's download link:

Cite As

Diego Oliva (2021). Multilevel Thresholding Segmentation Based on Harmony Search Optimization (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (4)

Priyanka Roy

Dear Diego,

Im working on multilevel thresholding for medical image segmentation. For comparative analysis i've executed your MLT Harmony Search Optimization and getting some error.
The error is :

Undefined function 'pa_range' for input arguments of type 'double'.

Error in Mth_HS1 (line 118)
pa = (range(j,2) - range(j,1)) / pa_range(j);

Can you please help me so that i could resolve the error.


sir help me by providing code for multilevel thresholding by kapur method

Diego Oliva

Hi Vetri, the variable:

m = number of elements (threholds) to be evaluated in the Kapurs function,e.g. the HM size or the population size.

PI = the probability distribution of each intensity level.

xR = the solution to be evaluated, could be the entire population or only one element.

level = number of threshold to find.

Thanks for the interes and don't forget to download and read the paper.


in the kapur method how to determine level, m, PI, and xR

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

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!