Particle segmentation algorithm for flexible single particle reconstruction