        ## finding the "greatest" range
        ranges = [0, 0, 0]
        for i in range(3): ## RGB iteration
            ranges[i] = np.max(flat_image[:,i]) - np.min(flat_image[:,i])
        max_range_index = np.argmax(ranges)

        ## sorting the image by the greatest axis
        flat_image = flat_image[flat_image[:,max_range_index].argsort()]
        middle_index = int((len(flat_image)-1)/2)