fig. 1 - Original Image
fig. 2 - Skeleton
As the goal requires, it is necessary now to clear all the small objects from figure 2. This is possible using another morphological operator: the N-Thinning. The operator will cut each object by their ending points the necessary to clear only the small ones. The parameter N is set accordingly to the length of the small objects. The result of this operator is shown in figure 3.
fig. 3 - N-Thinning
Now, it is possible to reconstruct the longer objects applying Opening by Reconstr. and using the result of the N-Thinning as markers for the original image. The result is shown bellow.
fig. 4 - Reconstruction