tryMergeBands method
Attempts to merge adjacent bands that are close enough horizontally.
Iterates through the list of bands and tries to merge each band with its immediate neighbor if they meet the horizontal proximity criteria.
Returns true if a merge was successful, false otherwise.
Implementation
bool tryMergeBands(List<Band> bandOnPossibleRow) {
for (int i = 0; i < bandOnPossibleRow.length - 1; i++) {
Band bandWest = bandOnPossibleRow[i];
Band bandEast = bandOnPossibleRow[i + 1];
if (shouldMergeBands(bandWest, bandEast)) {
bandWest.addArtifacts(bandEast.artifacts);
list.remove(bandEast);
bandOnPossibleRow.remove(bandEast);
return true;
}
}
return false;
}