fixed a bug when the given image has no segments (all zeros)