def main(): parser = argparse.ArgumentParser(description='Visualizes the line for hough transform.') parser.add_argument('filename') args = parser.parse_args() # img = cv2.imread(args.filename, cv2.IMREAD_GRAYSCALE) img = cv2.imread(args.filename) cv2.imshow('input', img) blur_image = SmoothImage('Blur', img, average_filter_size=5, gaussian_filter_size=1, median_filter_size=1, bilateral_filter_size=1) edge_finder = EdgeFinder('Edge', blur_image.processedImage(), min_threshold=28, max_threshold=115) blur_image.addProcessor (edge_finder.onImageChange) # will inforce refresh for all pipeline. blur_image.refresh() cv2.waitKey(0) # print ("Edge parameters: %s") # print ("GaussianBlur Filter Size: %f" % edge_finder.filterSize()) # print ("Threshold2: %f" % edge_finder.threshold2()) (head, tail) = os.path.split(args.filename) (root, ext) = os.path.splitext(tail) smoothed_filename = os.path.join("output_images", root + "-smoothed" + ext) edge_filename = os.path.join("output_images", root + "-edges" + ext) cv2.imwrite(smoothed_filename, edge_finder.processedImage()) cv2.imwrite(edge_filename, edge_finder.processedImage()) cv2.destroyAllWindows()
def main(): parser = argparse.ArgumentParser( description='Visualizes the line hough transform.') parser.add_argument('filename') args = parser.parse_args() img = cv2.imread(args.filename, cv2.IMREAD_GRAYSCALE) cv2.imshow('input', img) edge_finder = EdgeFinder(img, filter_size=13, threshold1=28, threshold2=115) print "Edge parameters:" print "GaussianBlur Filter Size: %f" % edge_finder.filterSize() print "Threshold1: %f" % edge_finder.threshold1() print "Threshold2: %f" % edge_finder.threshold2() (head, tail) = os.path.split(args.filename) (root, ext) = os.path.splitext(tail) smoothed_filename = os.path.join("output_images", root + "-smoothed" + ext) edge_filename = os.path.join("output_images", root + "-edges" + ext) cv2.imwrite(smoothed_filename, edge_finder.smoothedImage()) cv2.imwrite(edge_filename, edge_finder.edgeImage()) cv2.destroyAllWindows()
def main(): # parser for the command line input (automaticlly generates help) parser = argparse.ArgumentParser( description='Visualizes the line for hough transform.') parser.add_argument('filename') # save the arguments args = parser.parse_args() # read the image given as an argument img = cv2.imread(args.filename) # create the edge finding and gui class edge_finder = EdgeFinder(img, kernel_size=5) cv2.destroyAllWindows()
def main(): __init_logger() parser = argparse.ArgumentParser(description='Visualizes the line for hough transform.') parser.add_argument('filename') args = parser.parse_args() # img = cv2.imread(args.filename, cv2.IMREAD_GRAYSCALE) img = cv2.imread(args.filename) cv2.imshow('input', img) blur_image = SmoothImage('Bluring Config', img, average_filter_size=5, gaussian_filter_size=1, median_filter_size=1, bilateral_filter_size=1) edge_finder = EdgeFinder('Edge Finder Config', blur_image.processedImage(), min_threshold=28, max_threshold=115) blur_image.addProcessor (edge_finder.onImageChange) region_mask = RegionMask('Region Masked dimensions', edge_finder.processedImage()) edge_finder.addProcessor (region_mask.onImageChange) hough_lines = HoughLines('Hough Lines Config', region_mask.processedImage()) region_mask.addProcessor (hough_lines.onImageChange) image_blender = ImageBlender('Image Mix Config', hough_lines.processedImage(), img) hough_lines.addProcessor (image_blender.onImageChange) # will inforce refresh for all pipeline. blur_image.refresh() cv2.waitKey(0) print ("Adjust the parameters as desired. Hit any key to close. Your configuration will be in Tuning_info_out.log") logger.info("Configuration parameters:\n %s %s %s %s %s", blur_image, edge_finder, region_mask, hough_lines, image_blender) logger.debug("Configuration parameters:\n %s %s %s %s %s", blur_image, edge_finder, region_mask, hough_lines, image_blender) (head, tail) = os.path.split(args.filename) (root, ext) = os.path.splitext(tail) smoothed_filename = os.path.join("output_images", root + blur_image.name() + ext) edge_filename = os.path.join("output_images", root + edge_finder.name() + ext) maskeed_filename = os.path.join("output_images", root + region_mask.name() + ext) hough_filename = os.path.join("output_images", root + hough_lines.name() + ext) blended_filename = os.path.join("output_images", root + image_blender.name() + ext) cv2.imwrite(smoothed_filename, blur_image.processedImage()) cv2.imwrite(edge_filename, edge_finder.processedImage()) cv2.imwrite(maskeed_filename, region_mask.processedImage()) cv2.imwrite(hough_filename, hough_lines.processedImage()) cv2.imwrite(blended_filename, image_blender.processedImage()) cv2.destroyAllWindows()
def main(): parser = argparse.ArgumentParser( description='Visualizes the line for hough transform.') parser.add_argument('filename') args = parser.parse_args() file_list = os.listdir(args.filename) for image_name in file_list: print(f'****************{image_name}*******************') initial_img = mpimg.imread(args.filename + image_name) edge_finder = EdgeFinder(initial_img, filter_size=13, threshold1=28, threshold2=115) print("Edge parameters:") print("GaussianBlur Filter Size: %f" % edge_finder.filterSize()) print("Threshold1: %f" % edge_finder.threshold1()) print("Threshold2: %f" % edge_finder.threshold2()) print("Rho: %f" % edge_finder.rho()) print("Theta: %f" % edge_finder.theta()) print("Points Threshold: %f" % edge_finder.threshold()) print("max_line_gap: %f" % edge_finder.max_line_gap()) print("min_line_len: %f" % edge_finder.min_line_len()) (head, tail) = (args.filename, image_name) (root, ext) = os.path.splitext(tail) final_filename = os.path.join("output_images", root + "-final" + ext) edge_filename = os.path.join("output_images", root + "-edges" + ext) cv2.imwrite(edge_filename, edge_finder.edgeImage()) cv2.imwrite(final_filename, edge_finder.finalImage()) cv2.destroyAllWindows()