ternaus/TernausNetV2

contour creation

A-Jacobson opened this issue · 8 comments

Hey Vladimir,

In one of the other issues you shared your contour creation function:

def create_contour(labels):
    mask = labels.copy()
    mask[mask > 0] = 1
    dilated = binary_dilation(mask, iterations=4)
    mask_wl = watershed(dilated, labels, mask=dilated, watershed_line=True)
    mask_wl[mask_wl > 0] = 1
    contours = dilated - mask_wl
    contours = binary_dilation(contours, iterations=3)
    return contours

Could you please also share what's going on with the binary_dilation function? I don't believe that's the standard skimage function. Are you trying to adaptively set the dilation amount like the winners of the 2018 DSB did?

from scipy.ndimage import binary_dilation, binary_erosion, binary_closing

I found the code you provided was not correct . It should be

def create_contour(labels):
mask = labels.copy()
mask[mask > 0] = 1
dilated = binary_erosion(mask, iterations=4)
mask_wl = watershed(dilated, labels, mask=dilated, watershed_line=True)
mask_wl[mask_wl > 0] = 1
contours = dilated - mask_wl
contours = binary_dilation(contours, iterations=3)
return contours

My question is if we got the cotours, how to get the binary mask in which we predict areas of an image where different objects touch or very close to each other.

This function should directly return such a binary mask.

@antran89 follow this thread

@ternaus Thank you for your code. But the code cannot produce any building touches with your functions on Shanghai and Khartoum dataset.

Building mask of an image (MUL-PanSharpen_AOI_4_Shanghai_img125):

mul-pansharpen_aoi_4_shanghai_img125.png

Building touches mask:
mul-pansharpen_aoi_4_shanghai_img125

from skimage.measure import label
contour = create_contour(label(mask))

should do the job.

@ternaus Thank you for your quick responses. Happy weekend. Without your help, I could not reproduce the mask.
Oh, we need to use another function for the input mask.

mul-pansharpen_aoi_4_shanghai_img125