Research Article

Multilevel Thresholding Segmentation Based on Harmony Search Optimization

Algorithm 2

  1. Read the image and if it is RGB separate it into , and . If is gray scale store it into . for RGB images or for gray scale images.
  2. Obtain histograms: for RGB images , , and for gray scale images .
  3. Calculate the probability distribution using (7) and obtain the histograms.
  4. Initialize the HSA parameters: HMS, , HMCR, PAR, BW, NI, and the limits and .
  5. Initialize a HM of HMS random particles with dimensions.
  6. Compute the values and . Evaluate each element of in the objective function (14) or (20) depending on the thresholding method (Otsu or Kapur respectively).
  7. Improvise a new harmony as follows:
  for do
  if then
     where
    if then
      where
    end if
    if
     
    end if
    if
     
    end if
  else
      whew
  end if
  end for
  8. Update the as
  9. If NI is completed or the stop criteria is satisfied, then jump to 10; otherwise go back to 6.
  10. Select the harmony that has the best objective function value.
  11. Apply the thresholds values contained in to the image (6).