I am using an autoencoder to denoise gray-scale images of high resolution. Each image is divided into sub-batches of a particular size i.e 52 x 52 and the model works on each of these batches then the result is the concatenation of the denoised batches in each image back to the original one. Below is an example of an image after the result:
You can see the smaller image batches after concatenation. How to overcome this behavior?
I thought about doing further processing like adding blur to the edges to blend them together, however I think this is not the optimal solution.
code of concatenation:
num_hor_patch = 19
num_ver_patch = 26
print("Building the Images Batches")
for i in range(num_image):
reconstruct = []
for j in range(num_hor_patch):
from_vertical_patches = predictions[start_pos:(start_pos+num_ver_patch)]
horizontal_patch = np.concatenate(from_vertical_patches, axis=1)
start_pos += num_ver_patch
reconstruct.append(horizontal_patch)
restored_image = np.concatenate(np.array(reconstruct), axis=0)
output.append(restored_image)
start_pos = 0
test_data = np.array([np.reshape(test_data[i], (52, 52)) for i in range(test_data.shape[0])])
for i in range(num_image):
reconstruct = []
for j in range(num_hor_patch):
from_vertical_patches = test_data[start_pos:(start_pos+num_ver_patch)]
horizontal_patch = np.concatenate(from_vertical_patches, axis=1)
start_pos += num_ver_patch
reconstruct.append(horizontal_patch)
restored_image = np.concatenate(np.array(reconstruct), axis=0)
input.append(restored_image)
start_pos = 0
test_noisy_data = np.array([np.reshape(test_noisy_data[i], (52, 52)) for i in range(test_noisy_data.shape[0])])
for i in range(num_image):
reconstruct = []
for j in range(num_hor_patch):
from_vertical_patches = test_noisy_data[start_pos:(start_pos+num_ver_patch)]
horizontal_patch = np.concatenate(from_vertical_patches, axis=1)
start_pos += num_ver_patch
reconstruct.append(horizontal_patch)
restored_image = np.concatenate(np.array(reconstruct), axis=0)
noisy.append(restored_image)
print("Exporting the Model")
output_model['output'] = output
output_model['original'] = input
output_model['noisy'] = noisy
