Integrated code for orientation and segmentation.