def image_to_column(images, filter_shape, stride, padding):
 (n_images, n_channels, height, width) = images.shape
 (f_height, f_width) = filter_shape
 (out_height, out_width) = convoltuion_shape(height, width, (f_height, f_width), stride, padding)
 images = np.pad(images, ((0, 0), (0, 0), padding, padding), mode='constant')
 col = np.zeros((n_images, n_channels, f_height, f_width, out_height, out_width))
 for y in range(f_height):
  y_bound = (y + (stride[0] * out_height))
  for x in range(f_width):
   x_bound = (x + (stride[1] * out_width))
   col[:, :, y, x, :, :] = images[:, :, y:y_bound:stride[0], x:x_bound:stride[1]]
 col = col.transpose(0, 4, 5, 1, 2, 3).reshape(((n_images * out_height) * out_width), (-1))
 return col

def image_to_column ( images , filter_shape , stride , padding ) : ( n_images , n_channels , height , width ) = images . shape ( f_height , f_width ) = filter_shape ( out_height , out_width ) = convoltuion_shape ( height , width , ( f_height , f_width ) , stride , padding ) images = np . pad ( images , ( ( 0 , 0 ) , ( 0 , 0 ) , padding , padding ) , mode = 'constant' ) col = np . zeros ( ( n_images , n_channels , f_height , f_width , out_height , out_width ) ) for y in range ( f_height ) : y_bound = ( y + ( stride [ 0 ] * out_height ) ) for x in range ( f_width ) : x_bound = ( x + ( stride [ 1 ] * out_width ) ) col [ : , : , y , x , : , : ] = images [ : , : , y : y_bound : stride [ 0 ] , x : x_bound : stride [ 1 ] ] col = col . transpose ( 0 , 4 , 5 , 1 , 2 , 3 ) . reshape ( ( ( n_images * out_height ) * out_width ) , ( - 1 ) ) return col
rearrange image blocks into columns .