public static PackedImage segment(PackedImage img, int level) {
		img = threshold(img, level);
		int index = 0;
		
		for (int r = 0; r < img.rows(); r++) {
		    for (int c = 0; c < img.cols(); c++) {
		    	if (img.at(r, c) == 0xffffff) { // If the pixel is white, change that region's color
		    		segmentRecursion(img, r, c, index);
		    		index++;
		    		if (index == 7) // Keeping the indexes in the range of COLOR's size
		    			index = 0;
		    	}
		    }
		}
		return img;
	}