Small bug repaired in segmentation.c

Possible crossing of image borders repaired.