def _mask_filter_result(result, mask):
 if (mask is None):
  result[0, :] = 0
  result[(-1), :] = 0
  result[:, 0] = 0
  result[:, (-1)] = 0
  return result
 else:
  mask = binary_erosion(mask, EROSION_SELEM, border_value=0)
  return (result * mask)

def _mask_filter_result ( result , mask ) : if ( mask is None ) : result [ 0 , : ] = 0 result [ ( - 1 ) , : ] = 0 result [ : , 0 ] = 0 result [ : , ( - 1 ) ] = 0 return result else : mask = binary_erosion ( mask , EROSION_SELEM , border_value = 0 ) return ( result * mask )
return result after masking .