def main(): init = util.readImage('input/TestSeq/Shift0.png') final = util.readImage('input/TestSeq/ShiftR2.png') #final = util.readImage('input/TestSeq/ShiftR5U5.png') #final = util.readImage('input/TestSeq/ShiftR10.png') #final = util.readImage('input/TestSeq/ShiftR20.png') #final = util.readImage('input/TestSeq/ShiftR40.png') U, V = lk_flow(init, final) #U, V = hierarchical_lk(init, final) U = upscale(U) V = upscale(V) U = cv2.cvtColor(U, cv2.COLOR_GRAY2RGB) V = cv2.cvtColor(V, cv2.COLOR_GRAY2RGB) false_color_U = cv2.applyColorMap(U, cv2.COLORMAP_JET) false_color_V = cv2.applyColorMap(V, cv2.COLORMAP_JET) #namedWindow("window") cv2.imshow("U", false_color_U) cv2.imshow("V", false_color_V) import time time.sleep(30)
def main(): parser = argparse.ArgumentParser(description='Vision Simulator') parser.add_argument( 'pixel_map', type=str, help='An image of what a single white pixel looks like to you.') parser.add_argument('images', nargs='+', help='Images to apply your vision to.') parser.add_argument( '-n', '--norm-factor', default=1.7, type=float, help= 'The exponent factor used in normalizing pixel_map. You may have to adjust this value for good results.' ) parser.add_argument('-v', '--verbose', action='store_true', help='Run in verbose mode.') args = parser.parse_args() visionImg = util.readImage(args.pixel_map) visionMap = util.getBrightnessMap(visionImg, args.norm_factor) for path in args.images: image = util.readImage(path, convertToFloat=True) image = applyVision(visionMap, image, verbose=args.verbose) util.writeImage(path + '.vision.png', image)
def q1b(): init = util.readImage('input/TestSeq/Shift0.png') final = util.readImage('input/TestSeq/ShiftR10.png') plotDisplacements(init, final, 'output/ps5-1-b-1.png') final = util.readImage('input/TestSeq/ShiftR20.png') plotDisplacements(init, final, 'output/ps5-1-b-2.png') final = util.readImage('input/TestSeq/ShiftR40.png') plotDisplacements(init, final, 'output/ps5-1-b-3.png')
def main3(): init = util.readImage('input/TestSeq/Shift0.png') final = util.readImage('input/TestSeq/ShiftR2.png') U, V = lk_flow(init, final) warped = warp.warp(final, U, V) cv2.imshow("original", init) cv2.imshow("modified", warped) import time time.sleep(30)
def q3a(): image1 = util.readImage('input/DataSeq1/yos_img_01.jpg') image2 = util.readImage('input/DataSeq1/yos_img_02.jpg') image3 = util.readImage('input/DataSeq1/yos_img_03.jpg') q3helper(image1, image2, 1) q3helper(image2, image3, 5) image1 = util.readImage('input/DataSeq2/0.png') image2 = util.readImage('input/DataSeq2/1.png') image3 = util.readImage('input/DataSeq2/2.png') q3helper(image1, image2, 3) q3helper(image2, image3, 7)
def q2b(): image = util.readImage('input/DataSeq1/yos_img_01.jpg') gauPyr = pyramid.gaussPyramid(image, 3) lapPyr = pyramid.laplPyramid(gauPyr) q2_helper(lapPyr, 'output/ps5-2-b-2.png')
def q2a(): image = util.readImage('input/DataSeq1/yos_img_01.jpg') gauPyr = pyramid.gaussPyramid(image, 3) q2_helper(gauPyr, 'output/ps5-2-b-1.png')
def q1a(): init = util.readImage('input/TestSeq/Shift0.png') final = util.readImage('input/TestSeq/ShiftR2.png') final2 = util.readImage('input/TestSeq/ShiftR5U5.png') plotDisplacements(init, final, 'output/ps5-1-a-1.png') plotDisplacements(init, final2, 'output/ps5-1-a-2.png')
for key in metric_keys } for key in metric_keys: f = f_dict[key] f.write('name ') for i in range(1, num_class): f.write('OAR%d ' % (i)) f.write('average\n') count = 0 for patient in test_list: predict_path = os.path.join(predict_root_path, patient, 'predict.nii.gz') label_path = os.path.join(label_root_path, patient, 'label.nii.gz') predict = readImage(predict_path).astype(np.uint8) label = readImage(label_path) predict = one_hot(predict) label = one_hot(label) for key in metric_keys: f = f_dict[key] temp_list = [] temp_string = 'patient{} '.format(patient) for i in range(1, num_class): metric = metric_dict[key](label[..., i], predict[..., i]) temp_string += '%.4f ' % (metric) temp_list.append(metric) avg = average(temp_list) temp_string += '%.4f\n' % (avg)