@albanD  Maybe I’ve expressed unclearly.  The task is that: in every rectangular center on one pixel, I want to determine those pixel that stand on the same side with the central pixel, and those that don’t stand on the same side with the central pixel. For example, if for one central pixel, there are no edges go across the rectangular corresponding to the pixel, them we can conclude that all the pixel in that rentangular are standing on the same side with the central pixel. if there is a edge goes across the rectangular, them I need to seperate the pixel in the rectangular into two categories. One for those stand on same side with the central pixel, one for the others.