def resize_image(self, image): """ Appropriately resize a single image """ if self.resize_method == 'crop': # resize keeping aspect ratio resize_height = int(round(float(self.height) * self.resized_width / self.width)) resized = image_preprocessing.resize(image, (self.resized_width, resize_height)) # Crop the part we want crop_y_cutoff = resize_height - CROP_OFFSET - self.resized_height cropped = resized[crop_y_cutoff: crop_y_cutoff + self.resized_height, :] return cropped elif self.resize_method == 'scale': return image_preprocessing.resize(image, (self.resized_width, self.resized_height)) else: raise ValueError('Unrecognized image resize method.')
def hog_pipeline(gray_image, **kwargs): if 'binary_image' in kwargs: binary_image = kwargs['binary_image'] else: binary_image, _ = image_preprocessing(gray_image) return hog(resize(binary_image, 0.4), feature_vector=True, block_norm='L2-Hys')[:1000]
def get_observation(self): assert self.buffer_count >= self.buffer_length index = self.buffer_count % self.buffer_length - 1 max_image = self.screen_buffer[index] for i in xrange(1, self.buffer_length): max_image = np.maximum(max_image, self.screen_buffer[index - i, ...]) return image_preprocessing.resize(max_image, size=(self.flags.input_height, self.flags.input_width))
def resize_image(self, image): """ Appropriately resize a single image """ if self.resize_method == 'crop': # resize keeping aspect ratio resize_height = int(round( float(self.height) * self.resized_width / self.width)) resized = image_preprocessing.resize(image, (self.resized_width, resize_height)) # Crop the part we want crop_y_cutoff = resize_height - CROP_OFFSET - self.resized_height cropped = resized[crop_y_cutoff: crop_y_cutoff + self.resized_height, :] return cropped elif self.resize_method == 'scale': return image_preprocessing.resize(image, (self.resized_width, self.resized_height)) else: raise ValueError('Unrecognized image resize method.')