C sequence scanline segmentation implementation