def result_exposure(self, w_c=1, w_s=1, w_e=1): "Return the Exposure Fusion image with Laplacian/Gaussian Fusion method" print "weights" self.get_weights_map(w_c, w_s, w_e) print "gaussian pyramid" self.get_gaussian_pyramid_weights() print "laplacian pyramid" self.get_laplacian_pyramid_images() result_pyramid = [] for floor in range(self.height_pyr): print 'floor ', floor result_floor = np.zeros(self.laplacian_pyramid[0][floor].shape) for index in range(self.num_images): print 'image ', index for canal in range(3): result_floor[:, :, canal] += self.laplacian_pyramid[index][ floor][:, :, canal] * self.weights_pyramid[index][floor] result_pyramid.append(result_floor) # Get the image from the Laplacian pyramid self.result_image = result_pyramid[-1] for floor in range(self.height_pyr - 2, -1, -1): print 'floor ', floor self.result_image = result_pyramid[floor] + utils.Expand( self.result_image, 1) self.result_image[self.result_image < 0] = 0 self.result_image[self.result_image > 1] = 1 return self.result_image
def result_exposure(self): "Return the Exposure Fusion image with Laplacian/Gaussian Fusion method" print("weights") self.get_init_weights_map() print("guided pyramid") self.get_guided_pyramid_weights() print("laplacian pyramid") self.get_laplacian_pyramid_images() print("do images fusion") result_pyramid = [] for floor in range(self.T): #print ('floor ', floor) result_floor = np.zeros(self.laplacian_pyramid[0][floor].shape) for index in range(self.num_images): #print ('image ', index) for canal in range(3): result_floor[:, :,canal] += \ self.laplacian_pyramid[index][floor][:, :,canal] \ * self.weights_pyramid[index][floor] result_pyramid.append(result_floor) print("resconstuct HDR image") # Get the image from the Laplacian pyramid self.result_image = result_pyramid[-1] for floor in range(self.T - 2, -1, -1): #print ('floor ', floor) size = result_pyramid[floor].shape self.result_image = result_pyramid[floor] + utils.Expand( self.result_image, 1, size) self.result_image[self.result_image < 0] = 0 self.result_image[self.result_image > 1] = 1 print("done") return self.result_image
def get_laplacian_pyramid(self, image, n): """Return the Laplacian Pyramid of an image""" gaussian_pyramid_floors = self.get_gaussian_pyramid(image, n) laplacian_pyramid_floors = [gaussian_pyramid_floors[-1]] for floor in range(n - 2, -1, -1): new_floor = gaussian_pyramid_floors[floor] - utils.Expand( gaussian_pyramid_floors[floor + 1], 1) laplacian_pyramid_floors = [new_floor] + laplacian_pyramid_floors return laplacian_pyramid_floors