def __call__(self, sample): from envmap import EnvironmentMap image = EnvironmentMap(64, 'LatLong') image.data = sample rotation = self.random_direction() img_hdr = image.rotate('DCM', rotation).data.astype('float32') sample = img_hdr return sample
def rotate_image(data, rotation): """ rotation images with skylibs :param data: image data will be rotated, dimension is 4 [ x , width, height, 3] :return : weather rotated the images """ if [0.0, 0.0] == rotation: return False rotation_matrix = np.zeros([3, 3]) spherical2dcm(rotation, rotation_matrix) envmap = EnvironmentMap(data, format_='latlong') new_image = envmap.rotate("DCM", rotation_matrix).data data[:] = new_image.astype(np.uint8) return True
def rotate_image(self, data): """ rotation images with skylibs :param data: image data will be rotated, dimension is 4 [ x , width, height, 3] :return : weather rotated the images """ if [0.0, 0.0] == self.rotation: return data rotation_matrix = np.zeros([3, 3]) self.spherical2dcm(self.rotation, rotation_matrix) for i in range(0, np.shape(data)[0]): if i % self.show_infor_interval == 0: self.show_info( "Rotating image with 'rotate_image' function, index is {}." .format(i)) # show_image(image) image = data[i] envmap = EnvironmentMap(image, format_='latlong') new_image = envmap.rotate("DCM", rotation_matrix).data new_image = new_image.astype(np.uint8) data[i] = new_image return data
def rotate(self, rotation): envmap = EnvironmentMap(self.img, 'latlong') envmap.rotate('DCM', rotation.as_matrix()) self.img = envmap.data