I need to find and extract the edges of faced feature to each other. in other word, each point in one feature which can see the points from other feature is desired for me.

in my case, I have done several processes on my image and finally I have two features. I need to use the only edges which faces each other.

as illustration: the image A is the original one and the B has marked with blue line in the edges which i desire to extract for further process.

any idea, algorithm, description is welcomed.