Functions | |
def | PadAdiabatic |
PadAdiabatic is the padding function. We first allocate space for padded image.
def PadAdiabatic(A): # Subroutine for Neumann adiabatic extension along the boundary, # Input : gray image A of n x m; # Output: an expanded image (across four boundary edges) (n, m) = A.shape Ae = np.zeros((n+2, m+2), 'f')
Copy over the original image into the interior of the padded image that will be returned by the function.
for i in range(1,n+1): for j in range(1,m+1): Ae[i][j] = A[i-1][j-1]
Copy over each boundary to the boundary of the padded image, so that the padded image has values repeated at its boundaries
#the four boundary edges for j in range(1,m+1): Ae[0][j] = A[0][j-1] Ae[n+1,j] = A[n-1][j-1] for i in range(1,n+1): Ae[i][0]=A[i-1][0] Ae[i][m+1]=A[i-1][m-1]
Also copy over the corners from the original image to the padded image.
Ae[0][0]=A[0][0] Ae[0][m+1]=A[0][m-1] Ae[n+1][0]=A[n-1][0] Ae[n+1][m+1]=A[n-1][m-1]
Return the padded image.
return Ae
def PadAdiabatic.PadAdiabatic | ( | A | ) |