Input: random path through all ROIs (path_{0}), labels indicating which ROI corresponds to each path_{0} pixel (tags) |
Step 1. Find unique ROIs |
For ROI in unique(tags): Find ROI centroid |
Step 2. Find optimal path through ROIs centroids (path_{TSP}) applying genetic algorithm to solve TSP |
Randomly initialize a population of 100 individuals (random paths through all ROIs) Find minimum path length min_{glob} and the individual than minimize path length (path_{TSP}) For generation in [1:1000]: Compute the path length for each individual If exist a path shorter then min_{glob}, then update min_{glob} and path_{TSP} Randomly split population in groups of 4 individuals For each group of 4 individuals: Find the individual with shortest path Create 4 mutations (original, flip, swap, slide) of the individual for the next generation |
Step 3. Compute path_{SLS} |
Initialize empty trajectory path_{SLS} |
For ROI in path_{TSP}: Find path through all ROI’s pixels (path_{ROI}) using a greedy algorithm Append path_{ROI} to path_{TSP} |
Return: path_{TSP} |