def reconstruction_by_erosion(im, LEN, DEG_NUM):
    im_close = []
    for i in range(DEG_NUM):
        filtername = (str((i + 1)) + 'se.txt')
        se = np.loadtxt(('filters/images/filters/' + filtername))
        if (i == 0):
            se = np.reshape(se, (1, len(se)))
        if (i == 6):
            se = np.reshape(se, (len(se), 1))
        se = se.astype('uint8')
        im_closei = cv2.dilate(im, se)
        im_closei = cv2.erode(im_closei, se)
        im_close.append(im_closei)
    imTemp39 = im_close[0]
    for i in range((DEG_NUM - 1)):
        k = (i + 1)
        imTemp39 = np.minimum(imTemp39, im_close[k])
    marker = imcomplement(imTemp39)
    mask = imcomplement(im)
    imF = imreconstruct(marker, mask)
    imF = mat2gray(imF)
    imF = imcomplement(imF)
    return imF
def reconstruction_by_erosion(im, LEN, DEG_NUM):
    im_close = []
    for i in range(DEG_NUM):
        filtername = (str((i + 1)) + 'se.txt')
        se = np.loadtxt(('filters/images/filters/' + filtername))
        if (i == 0):
            se = np.reshape(se, (1, len(se)))
        if (i == 6):
            se = np.reshape(se, (len(se), 1))
        se = se.astype('uint8')
        im_closei = cv2.dilate(im, se)
        im_closei = cv2.erode(im_closei, se)
        im_close.append(im_closei)
    imTemp39 = im_close[0]
    for i in range((DEG_NUM - 1)):
        k = (i + 1)
        imTemp39 = np.minimum(imTemp39, im_close[k])
    marker = imcomplement(imTemp39)
    mask = imcomplement(im)
    imF = imreconstruct(marker, mask)
    imF = mat2gray(imF)
    imF = imcomplement(imF)
    return imF