It seems your input image is slightly different from the one you posted, since I could not directly collect the branch points (there were too many of them). So, to begin processing your problem, I consider thinning, followed by detection of a branch point. I also expand them and remove them from the sparse image, this ensures that in fact there is no connection (4 or 8) between the different segments of the original image.
f = im2bw(imread('http://i.imgur.com/yeFyF.png'), 0); g = bwmorph(f, 'thin', 'Inf'); h = g & ~bwmorph(bwmorph(g, 'branchpoints'), 'dilate');
Since h contains disconnected segments, the following operation collects the endpoints of all segments:
u = bwmorph(h, 'endpoints');
Now, to solve your problem, I did a little analysis of what you want to drop. Consider two different segments, a and b , in h . We say that a and b overlap if the endpoints of the unit are contained in another. In terms of content, I simply mean if the starting point x of one is less than or equal to the other, and the ending x-point is greater than or equal to. In your case, the "mountain" overlaps with the segment that you want to delete. To identify each of them, you delete, consider their area. But, since these are segments, area is a meaningless term. To deal with this, I connected the endpoints of the segment and used just the internal points as the area. As you can clearly see, the area of ββthe overlapped segment below is very small, so we say that this is basically a line and discard it, preserving the "mountain" segment. To take this step, the u image is fundamental, because with it you clearly indicate where to start and stop tracing the outline. If you used image h as it is, you would have trouble figuring out where to start and stop picking contour points (that is, the raster order will give you the wrong indication of overlap).
To restore a segment as one (you currently have three of them), consider the points that you dropped from g to h , and use those that do not belong to the deleted lower segment.