Added regridding if the patch size is too small based on the physical scales.
Only delete connection that are less than 2 pixels wide.
Use nan masking for all to pick up image edges.
Fill small holes in the mask.