private static void segmentRecursion(PackedImage img, int r, int c, int index) {
		img.set(r, c, COLORS[index]);
		if (r-1 >= 0 && img.at(r-1, c) == 0xffffff) { // If the pixel above the current is white and not outside the image's dimensions
			segmentRecursion(img, r-1, c, index);
		}
		if (r+1 < img.rows() && img.at(r+1, c) == 0xffffff) { // If the pixel below the current is white and not outside the image's dimensions
			segmentRecursion(img, r+1, c, index);
		}
		if (c-1 >= 0 && img.at(r, c-1) == 0xffffff) { // If the pixel to the left of the current is white and not outside the image's dimensions
			segmentRecursion(img, r, c-1, index);
		}
		if (c+1 < img.cols() && img.at(r, c+1) == 0xffffff) { // If the pixel to the right of the current is white and not outside the image's dimensions
			segmentRecursion(img, r, c+1, index);
		}
	}