def do_tests(filename): image = core.load_image(filename) glyphs = image.cc_analysis() g = make_spanning_tree(glyphs) g_orig = g.copy() c = make_subtrees_stddev(g, 1.5) gamera_xml.glyphs_to_xml( c, os.path.abspath( os.path.dirname(filename) + "cluster_1_5_" + os.path.basename(filename))) g = g_orig.copy() c = make_subtrees_stddev(g, 2.0) gamera_xml.glyphs_to_xml( c, os.path.abspath( os.path.dirname(filename) + "cluster_2_0_" + os.path.basename(filename))) g = g_orig.copy() c = make_subtrees_stddev(g, 2.5) gamera_xml.glyphs_to_xml( c, os.path.abspath( os.path.dirname(filename) + "cluster_2_5_" + os.path.basename(filename))) g = g_orig.copy() c = make_subtrees_stddev(g, 3.0) gamera_xml.glyphs_to_xml( c, os.path.abspath( os.path.dirname(filename) + "cluster_3_0_" + os.path.basename(filename)))
def do_tests(filename): image = core.load_image(filename) glyphs = image.cc_analysis() g = make_spanning_tree(glyphs) g_orig = g.copy() c = make_subtrees_stddev(g, 1.5) gamera_xml.glyphs_to_xml(c, os.path.abspath(os.path.dirname(filename) + "cluster_1_5_" + os.path.basename(filename))) g = g_orig.copy() c = make_subtrees_stddev(g, 2.0) gamera_xml.glyphs_to_xml(c, os.path.abspath(os.path.dirname(filename) + "cluster_2_0_" + os.path.basename(filename))) g = g_orig.copy() c = make_subtrees_stddev(g, 2.5) gamera_xml.glyphs_to_xml(c, os.path.abspath(os.path.dirname(filename) + "cluster_2_5_" + os.path.basename(filename))) g = g_orig.copy() c = make_subtrees_stddev(g, 3.0) gamera_xml.glyphs_to_xml(c, os.path.abspath(os.path.dirname(filename) + "cluster_3_0_" + os.path.basename(filename)))
} ps = ProjectionSplitter(**kwargs) if inImage: image = image.to_onebit() image = ps._maybe_invert_image(image) cc_images = image.cc_analysis() cc_images = ps._filter_tiny_images(cc_images) output_glyphs = [] for g in cc_images: output_glyphs += ps.run(g) # output_glyphs = ps.run(image) # save all as images for i, g in enumerate(output_glyphs): g.save_PNG('./output/piece' + str(i + 1) + '.png') elif inXML: output_glyphs = [] for g in glyphs: output_glyphs += ps.run(g) gamera_xml.glyphs_to_xml('./output/output.xml', output_glyphs) print('do stuff')
def glyphs_to_xml(self, event): from gamera import gamera_xml filename = gui_util.save_file_dialog(None, gamera_xml.extensions) if filename != None: gamera_xml.glyphs_to_xml(filename, self.data)
def test_glyphs_to_xml_gz(): glyphs = gamera_xml.glyphs_from_xml("data/testline.xml") gamera_xml.glyphs_to_xml("tmp/testline_test1.xml.gz", glyphs, False) assert equal_files("tmp/testline_test1.xml.gz", "data/testline_test1.xml.gz", gz=True)
def test_glyphs_to_xml_with_features(): glyphs = gamera_xml.glyphs_with_features_from_xml("data/testline.xml", feature_functions=features) gamera_xml.glyphs_to_xml("tmp/testline_test2.xml", glyphs, True) assert equal_files("tmp/testline_test2.xml", "data/testline_test2.xml")
def test_glyphs_to_xml_gz(): glyphs = gamera_xml.glyphs_from_xml("data/testline.xml") gamera_xml.glyphs_to_xml("tmp/testline_test1.xml.gz", glyphs, False) assert equal_files("tmp/testline_test1.xml.gz", "data/testline_test1.xml.gz", gz=True)
def test_glyphs_to_xml_with_features(): glyphs = gamera_xml.glyphs_with_features_from_xml("data/testline.xml", feature_functions=features) gamera_xml.glyphs_to_xml("tmp/testline_test2.xml", glyphs, True) assert equal_files("tmp/testline_test2.xml", "data/testline_test2.xml")
def glyphs_to_xml(self, event): from gamera import gamera_xml filename = gui_util.save_file_dialog(None, gamera_xml.extensions) if filename != None: gamera_xml.glyphs_to_xml(filename, self.data)
if guess[0][0][0] > .015: sz = c.ncols * c.nrows size_predictor.append(sz) candidates = [] #for glyphs conforming to average size for c in component_list: size = c.ncols*c.nrows if size > min(size_predictor)*.5 and size < max(size_predictor)*2: #rule out by size arr = c.to_numpy()/c.label #1s and 0s, 1 is black print arr candidates.append(arr) #test haar for arr in candidates: integral = cv2.integral(arr) print h.hor_2(arr, integral) # Display the ccs to show their classification #display_multi(classifiedimgs) #Inspect performance in GUI gamera_xml.glyphs_to_xml("knn-results.xml", component_list, False)