def output(partIdx): """Uses the student code to compute the output for test cases.""" outputString = '' if partIdx == 0: # reduce and expand outputString = str(int(part0.test())) elif partIdx == 1: # gauss_pyr and lapl_pyr outputString = str(int(part1.test())) elif partIdx == 2: # blend and collapse outputString = str(int(part2.test())) return outputString
def output(partIdx): """Uses the student code to compute the output for test cases.""" outputString = '' if partIdx == 0: # splitrgb outputString = str(int(part0.test())) elif partIdx == 1: # interlace outputString = str(int(part1.test())) elif partIdx == 2: # greyscale outputString = str(int(part2.test())) return outputString
def output(partIdx): """Uses the student code to compute the output for test cases.""" outputString = '' if partIdx == 0: outputString = str(int(part0.test())) elif partIdx == 1: outputString = str(int(part1.test())) elif partIdx == 2: outputString = str(int(part2.test())) return outputString
def output(partIdx): """Uses the student code to compute the output for test cases.""" outputString = '' if partIdx == 0: # convolve outputString = str(int(part0.test())) elif partIdx == 1: # gaussian outputString = str(int(part1.test())) elif partIdx == 2: # sharpen outputString = str(int(part2.test())) elif partIdx == 3: # median outputString = str(int(part3.test())) elif partIdx == 4: # theta and mag outputString = str(int(part4.test())) return outputString
def main(): datasets = getDatasets(regressors, regressand) # Part 1 Training and Testing print('P1 -- Training') p1_model = part1.LinRegModel(draw_plots) p1_training_mse, p1_weights_v = part1.train(p1_model, datasets) p1_testing_mse = part1.test(p1_model, datasets) print('P1 -- Training MSE: %.2f' % (p1_training_mse)) print('P1 -- Testing MSE: %.2f' % (p1_testing_mse)) # Part 2 Training and Testing print('P2 -- Training') p2_model = linear_model.LinearRegression() p2_training_mse, p2_weights_v = part2.train(p2_model, datasets) p2_testing_mse = part2.test(p2_model, datasets) print('P2 -- Training MSE: %.2f' % (p2_training_mse)) print('P2 -- Testing MSE: %.2f' % (p2_testing_mse))
if __name__ == "__main__": # Testing code -------------------------------------------------------------- # feel free to modify this to try out different filters and parameters. print "-"*15 + "part0" + "-"*15 t0 = part0.test() print "Unit test: {}".format(t0) conv_func = signal.convolve2d if t0: conv_func = part0.convolve apply_filter(conv_func, box_filter(2), 'box2') else: print "Please test your code using part0.py prior to using this function." print "-"*15 + "part1" + "-"*15 t1 = part1.test() print "Unit test: {}".format(t1) if t1: apply_filter(conv_func, part1.make_gaussian(5,3), 'gaussian5_3') else: print "Please test your code using part1.py prior to using this function." print "-"*15 + "part2" + "-"*15 t2 = part2.test() print "Unit test: {}".format(t2) if t2: apply_filter(conv_func, part2.make_sharp(5,3), 'sharp5_3') else: print "Please test your code using part2.py prior to using this function." print "-"*15 + "part3" + "-"*15
if __name__ == "__main__": # Testing code -------------------------------------------------------------- # feel free to modify this to try out different filters and parameters. print "-" * 15 + "part0" + "-" * 15 t0 = part0.test() print "Unit test: {}".format(t0) conv_func = signal.convolve2d if t0: conv_func = part0.convolve apply_filter(conv_func, box_filter(2), 'box2') else: print "Please test your code using part0.py prior to using this function." print "-" * 15 + "part1" + "-" * 15 t1 = part1.test() print "Unit test: {}".format(t1) if t1: apply_filter(conv_func, part1.make_gaussian(5, 3), 'gaussian5_3') else: print "Please test your code using part1.py prior to using this function." print "-" * 15 + "part2" + "-" * 15 t2 = part2.test() print "Unit test: {}".format(t2) if t2: apply_filter(conv_func, part2.make_sharp(5, 3), 'sharp5_3') else: print "Please test your code using part2.py prior to using this function." print "-" * 15 + "part3" + "-" * 15
diff3 = np.zeros(diff2.shape, float) for i in range(diff2.shape[0]): for j in range(diff2.shape[1]): diff3[i,j] = alpha*(i-j) - diff2[i,j] return viz_diff(diff1), viz_diff(diff2), viz_diff(diff3),\ part2.synthesize_loop(video_volume, idxs[0]+2, idxs[1]+2) if __name__ == "__main__": print 'Performing unit tests.' if not part0.test(): print 'part0 failed. halting' sys.exit() if not part1.test(): print 'part1 failed. halting' sys.exit() if not part2.test(): print 'part2 failed. halting' sys.exit() print 'Unit tests passed.' sourcefolder = os.path.abspath(os.path.join(os.curdir, 'videos', 'source')) outfolder = os.path.abspath(os.path.join(os.curdir, 'videos', 'out')) print 'Searching for video folders in {} folder'.format(sourcefolder) # Extensions recognized by opencv exts = ['.bmp', '.pbm', '.pgm', '.ppm', '.sr', '.ras', '.jpeg', '.jpg',
outimg < 0] = 0 # blending sometimes results in slightly out of bound numbers. outimg[outimg > 255] = 255 outimg = outimg.astype(np.uint8) return lapl_pyr_black, lapl_pyr_white, gauss_pyr_black, gauss_pyr_white, \ gauss_pyr_mask, outpyr, outimg if __name__ == "__main__": print 'Performing unit tests.' if not part0.test(): print 'part0 failed. halting' sys.exit() if not part1.test(): print 'part1 failed. halting' sys.exit() if not part2.test(): print 'part2 failed. halting' sys.exit() print 'Unit tests passed.' sourcefolder = os.path.abspath(os.path.join(os.curdir, 'images', 'source')) outfolder = os.path.abspath(os.path.join(os.curdir, 'images', 'output')) print 'Searching for images in {} folder'.format(sourcefolder) # Extensions recognized by opencv exts = [