Skip to main content
. 2019 Mar 23;21(3):318. doi: 10.3390/e21030318
Algorithm 1 Pseudo code of whale optimization algorithm based multilevel thresholding
Initialize the position of whales Xi.
Initialize the best search agent X*.
 WHILE t < Maximum number of iterations
  FOR i = 1:n
   Calculate the objective value of each search agent by using the Equation (1) for Kapur’s entropy.
   Update the best search agent X*.
   Update a, A, C, r, and p
   IF1 p < 0.5
    IF2 |A| < 1
     Update the position of search agent using Equations (7) and (8).
    ELSE
     Update the position of search agent using Equations (14) and (15).
    END IF2
   ELSE
    Update the position of search agent using Equations (11) and (12).
   END IF1
   Correct the position of the current search agent if it is beyond the border.
  END FOR
 END WHILE
Return X*, which represents the optimal threshold values of segmentation.