def _shift_selem(selem, shift_x, shift_y):
 if (selem.ndim > 2):
  return selem
 (m, n) = selem.shape
 if ((m % 2) == 0):
  extra_row = np.zeros((1, n), selem.dtype)
  if shift_x:
   selem = np.vstack((selem, extra_row))
  else:
   selem = np.vstack((extra_row, selem))
  m += 1
 if ((n % 2) == 0):
  extra_col = np.zeros((m, 1), selem.dtype)
  if shift_y:
   selem = np.hstack((selem, extra_col))
  else:
   selem = np.hstack((extra_col, selem))
 return selem

def _shift_selem ( selem , shift_x , shift_y ) : if ( selem . ndim > 2 ) : return selem ( m , n ) = selem . shape if ( ( m % 2 ) == 0 ) : extra_row = np . zeros ( ( 1 , n ) , selem . dtype ) if shift_x : selem = np . vstack ( ( selem , extra_row ) ) else : selem = np . vstack ( ( extra_row , selem ) ) m += 1 if ( ( n % 2 ) == 0 ) : extra_col = np . zeros ( ( m , 1 ) , selem . dtype ) if shift_y : selem = np . hstack ( ( selem , extra_col ) ) else : selem = np . hstack ( ( extra_col , selem ) ) return selem
shift the binary image selem in the left and/or up .