def main(args): # timer tic = time.time() # load images high_img = read(args.img, color=args.color) low_img = read(args.low_img, color=args.color) high_img, low_img = align_images(high_img, low_img) # call function on each image channel for d in range(high_img.shape[2]): high_img[:, :, d] = combine(high_img[:, :, d], low_img[:, :, d], sigma=args.sigma, size=args.kernel_size) # show image in original format and rgb show(high_img) if args.save: save(high_img, args.low_img, sigma=args.sigma, img2=os.path.basename(args.img)) toc = time.time() print("Time elapsed: " + str(toc - tic))
required=True, help="path to input image that we'll assign to template") ap.add_argument("-t", "--template", required=True, help="path to input template image") ap.add_argument("-d", "--debug", required=False, help="enter True to run in debug mode") args = vars(ap.parse_args()) print("[Info] loading images...") image = cv2.imread(args["image"]) template = cv2.imread(args["template"]) print("[Info] aligning images...") aligned = align_images.align_images(image, template, debug=args["debug"]) aligned = imutils.resize(aligned, width=700) template = imutils.resize(template, width=700) stacked = np.hstack([aligned, template]) overlay = template.copy() output = aligned.copy() cv2.addWeighted(overlay, 0.5, output, 0.5, 0, output) cv2.imshow("Image Alignment: Stacked", stacked) cv2.imshow("Image Alignment: Overlay", output) cv2.waitKey(0)
#im2 = skio.imread('./originals/bobbycar.jpg') #im1 = skio.imread('./originals/ferrari_gray.jpg') #im2 = skio.imread('./originals/old_man.jpeg') #im1 = skio.imread('./originals/matterhorn.jpg') #im2 = skio.imread('./originals/wolf.jpg') #im1 = skio.imread('./originals/1534638850129_gray.jpg') #im2 = skio.imread('./originals/frown.JPG') #im1 = skio.imread('./originals/smile_gray.JPG') im2 = skio.imread('./originals/flo_finale.jpg') im1 = skio.imread('./originals/me_boston.jpg') im1 = sk.img_as_float(im1) im2 = sk.img_as_float(im2) # use this if you want to align the two images (e.g., by the eyes) and crop # them to be of same size im2, im1 = align_images(im2, im1) # Choose the cutoff frequencies and compute the hybrid image (you supply # this code) arbitrary_value_1 = 7 arbitrary_value_2 = 10 cutoff_low = arbitrary_value_1 cutoff_high = arbitrary_value_2 im12 = hybrid_image(im1, im2, cutoff_low, cutoff_high) # Crop resulting image (optional) assert im12 is not None, "im12 is empty, implement hybrid_image!" im12 = crop_image(im12) im12 = sk.exposure.rescale_intensity(im12, in_range=(-1.0, 1.0))
def ResizeIMG(image): #calculate the 50 percent of original dimensions width = 700 (h, w) = image.shape[:2] r = width / float(w) dim = (width, int(h * r)) # resize image image = cv2.resize(image, dim) return image resized_template = ResizeIMG(template_img) if input_img is not None: resized_image = ResizeIMG(input_img) final_image = align_images(resized_image, resized_template, debug=True) else: final_image = resized_template # REGION OF INTEREST (ROI) SELECTION # initializing the list for storing the coordinates coordinates = [] # Defining the event listener (callback function) def shape_selection(event, x, y, flags, param): # making coordinates global global coordinates
def align_faces(self, path_from=RAW_IMAGES_PATH, path_to=ALIGNED_IMAGES_PATH): align_images(path_from, path_to)
print("Images loaded...") return cine_img, tagged_img, lm_coords return None, None, None if __name__ == '__main__': hdf5_filepath = "C:\\Users\\arad572\\Documents\\Summer Research\\code\\prepare_data\\h5_files\\sa-oc-lvsc_new-filenames.hdf5" my_hdf5_filepath = "C:\\Users\\arad572\\Documents\\Summer Research\\code\\prepare_data\\h5_files\\UK_Biobank_20cases.h5" patient_name = "2B UK 9P 26 Bio" dicom_filename = "1.3.12.2.1107.5.2.18.41754.2015060817574722496124508.dcm" my_cine_img, my_tagged_img, lm_coords = get_images(my_hdf5_filepath, dicom_filename) mask, img_hdf5 = get_mask(hdf5_filepath, dicom_filename) aligned_cine_img, aligned_mask = align_images(img_hdf5, my_cine_img, mask) print(aligned_cine_img.dtype, img_hdf5.dtype) plot_images(patient_name, aligned_cine_img, my_tagged_img, img_hdf5, mask, aligned_mask, lm_coords, save_image=False) #evaluate_on_hdf5('F://sa-oc-lvsc_new-filenames.hdf5') print('Finished')
required=True, help="path to input image that we'll align to template") ap.add_argument("-t", "--template", required=True, help="path to input template image") args = vars(ap.parse_args()) # load the input image and template from disk print("[INFO] loading images...") image = cv2.imread(args["image"]) template = cv2.imread(args["template"]) # align the images print("[INFO] aligning images...") aligned = align_images(image, template, debug=True) # resize both the aligned and template images so we can easily # visualize them on our screen aligned = imutils.resize(aligned, width=700) template = imutils.resize(template, width=700) # our first output visualization of the image alignment will be a # side-by-side comparison of the output aligned image and the # template stacked = np.hstack([aligned, template]) # our second image alignment visualization will be *overlaying* the # aligned image on the template, that way we can obtain an idea of # how good our image alignment is overlay = template.copy()