def defoveate_channel(img, rings, dense_input, start_idx):
 ring_w = numpy.sum(rings)
 inner_h = (img.shape[1] - (2 * ring_w))
 inner_w = (img.shape[2] - (2 * ring_w))
 end_idx = (start_idx + (inner_h * inner_w))
 inner_img = dense_input[:, start_idx:end_idx].reshape((-1), inner_h, inner_w)
 img[:, ring_w:(ring_w + inner_h), ring_w:(ring_w + inner_w)] = inner_img
 idx = 0
 start_idx = end_idx
 for rd in rings:
  start_idx = restore_ring(img, idx, rd, dense_input, start_idx)
  idx += rd
 return start_idx

def defoveate_channel ( img , rings , dense_input , start_idx ) : ring_w = numpy . sum ( rings ) inner_h = ( img . shape [ 1 ] - ( 2 * ring_w ) ) inner_w = ( img . shape [ 2 ] - ( 2 * ring_w ) ) end_idx = ( start_idx + ( inner_h * inner_w ) ) inner_img = dense_input [ : , start_idx : end_idx ] . reshape ( ( - 1 ) , inner_h , inner_w ) img [ : , ring_w : ( ring_w + inner_h ) , ring_w : ( ring_w + inner_w ) ] = inner_img idx = 0 start_idx = end_idx for rd in rings : start_idx = restore_ring ( img , idx , rd , dense_input , start_idx ) idx += rd return start_idx
defoveate a single channel of the densedesignmatrix dense_input into the variable .