Research Article

Medical Image Segmentation Using Fruit Fly Optimization and Density Peaks Clustering

Algorithm 2

FOA-DPC Algorithm.
Input: Medical images, population size Sizepop, number of iterations Maxgen, the initial position of the fruit fly X_axis and Y_axis.
(1)Begin
(2)Initial: Initialize coordinate points.
(3)X_axis = randi([imin,imax],1,1)
(4)Y_axis = randi([imin,imax],1,1) % The initial position of the fruit flies, the range is imin to imax.
(5)X_axis; Y_axis % Assign X_axis, Y_axis to DPC parameters.
(6)Xa = X_axis + randi()
(7)Ya = Y_axis + randi() % Give fruit flies random directions and distances
(8)Calculate: Calculate the smell concentration function fit with image entropy and record the test result in the smell concentration array (Smell).
(9)[bestSmell,bestIndex]=max(Smell) % Find extremum based on initial smell concentration
(10)Smellbest = bestSmell
(11)X_axis = S(bestIndex,1)
(12)Y_axis = S(bestIndex,2) % Keep the best position
(13)For i = 1 to Maxgen % Fruit flies begin iterative optimization, looking for multiple extremum
(14) For j = 1 to Sizepop
(15)  If Smellbest>bestSmell then
(16)   X(bestIndex)⟶X_axis
(17)   Y(bestIndex)⟶Y_axis
(18)   SmellbestbestSmell
(19)  End If
(20)End
(21)Return optimal parameter values and segmentation results.
Output: Optimal threshold, image segmentation results