Postprocessing

The tricks in solving the problem aren't over yet. As mentioned in the Preprocessing subsection, we standardize the pixel values between -1 to +1 for the purpose of ensuring that our network trains properly. Also, the LAB colorspace has values between -128 and +128 for the two color channels. Thus, the following two postprocessing steps are performed:

  • We multiply each pixel value by 128 to bring values into the required range of color channels
  • We concatenate the grayscale input image with the output two-channel image to achieve the hallucinated color image

The following snippet performs the postprocessing steps to achieve hallucinated color images:

sample_img = []
for filename in test_files:
sample_img.append(sp.misc.imresize(load_img(IMG_DIR+filename),
(DIM, DIM)))
sample_img = np.array(sample_img,
dtype=float)
sample_img = 1.0/255*sample_img
sample_img = gray2rgb(rgb2gray(sample_img))
sample_img = rgb2lab(sample_img)[:,:,:,0]
sample_img = sample_img.reshape(sample_img.shape+(1,))
#embedding input
sample_img_embed = create_vgg_embedding(sample_img)

As shown in the preceding code snippet, we use the lab2rgb utility from skimage to transform the produced output into RGB colorspace. This is done for the ease of visualizing the output image.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.128.203.137