parameters: (self, im, seg_label, scale)
return_statement: return im, seg_label
docstring: preprocess() emulate the pre-processing occurring in the vgg16 caffe
          prototxt.
docstring_summary: preprocess() emulate the pre-processing occurring in the vgg16 caffe
          prototxt.
docstring_tokens: preprocess () emulate the pre - processing occurring in the vgg16 caffe prototxt .
function: def preprocess(self, im, seg_label, scale):
          """
          preprocess() emulate the pre-processing occurring in the vgg16 caffe
          prototxt.
          """
          ##process input image
          assert im.dtype == np.uint8;
          im = np.float32(im)
          im = im[:, :, ::-1]  # change to BGR
          # subtract mean values
          # im[:, :, 0] -= self.mean_values[0];
          # im[:, :, 1] -= self.mean_values[1];
          # im[:, :, 2] -= self.mean_values[2];
          im -= self.mean_values;
          
          ###### rescale images ########
          
          # generate a new scale (new_h, new_w)
          new_h = int(im.shape[0] * float(scale));
          new_w = int(im.shape[1] * float(scale));
          interpolation_ = cv2.INTER_LINEAR;
          im = self.scale_img(im, new_h, new_w, interpolation_, False);
          
          ##process segmentation label map
          assert seg_label.dtype == np.uint8;
          interpolation_ = cv2.INTER_NEAREST;
          seg_label = self.scale_img(seg_label, new_h, new_w, interpolation_, False);
          
          ##### crop rescaled images #####
          
          # generate a random starting point for all images
          rand_y = random.randint(0, im.shape[0] - self.crop_size);
          rand_x = random.randint(0, im.shape[1] - self.crop_size);
          # rgb
          im = self.random_crop_img(im, rand_y, rand_x);
          # seg
          seg_label = self.random_crop_img(seg_label, rand_y, rand_x);
                 
          im = im.transpose((2, 0, 1));
          #seg_lable = seg_label[np.newaxis, ...];
          seg_label = seg_label.reshape(1, self.crop_size, self.crop_size);
  
          return im, seg_label
function_tokens: def preprocess ( self , im , seg_label , scale ) : ##process input image assert im . dtype == np . uint8 im = np . float32 ( im ) im = im [ : , : , : : - 1 ] # change to BGR # subtract mean values # im[:, :, 0] -= self.mean_values[0]; # im[:, :, 1] -= self.mean_values[1]; # im[:, :, 2] -= self.mean_values[2]; im -= self . mean_values ###### rescale images ######## # generate a new scale (new_h, new_w) new_h = int ( im . shape [ 0 ] * float ( scale ) ) new_w = int ( im . shape [ 1 ] * float ( scale ) ) interpolation_ = cv2 . INTER_LINEAR im = self . scale_img ( im , new_h , new_w , interpolation_ , False ) ##process segmentation label map assert seg_label . dtype == np . uint8 interpolation_ = cv2 . INTER_NEAREST seg_label = self . scale_img ( seg_label , new_h , new_w , interpolation_ , False ) ##### crop rescaled images ##### # generate a random starting point for all images rand_y = random . randint ( 0 , im . shape [ 0 ] - self . crop_size ) rand_x = random . randint ( 0 , im . shape [ 1 ] - self . crop_size ) # rgb im = self . random_crop_img ( im , rand_y , rand_x ) # seg seg_label = self . random_crop_img ( seg_label , rand_y , rand_x ) im = im . transpose ( ( 2 , 0 , 1 ) ) #seg_lable = seg_label[np.newaxis, ...]; seg_label = seg_label . reshape ( 1 , self . crop_size , self . crop_size ) return im , seg_label