def test_conversion_color2(): img = Image.fromGslib("tests/data/test_color.gslib") img.exportAsPng("tests/data/test_color.png", colored=True) img = Image.fromGslib("tests/data/test_color.gslib") img.exportAsPpm("tests/data/test_color.ppm") img2 = Image.fromPng("tests/data/test_color.png") img3 = Image.fromPpm("tests/data/test_color.ppm") assert np.alltrue((img.asArray()-img2.asArray()) < 1e8) assert img == img3
def test_import_gslb2var(): img = Image.fromGslib("tests/data/2var.gslib") var1 = img.asArray("V0").reshape((3, 3)) var2 = img.asArray("V1").reshape((3, 3)) expected1 = np.array([[1, 1, 1], [1, 1, 1], [0, 0, 0]]) expected2 = np.array([[1, 0, 1], [0, 1, 0], [1, 0, 1]]) assert np.alltrue(var1 == expected1) assert np.alltrue(var2 == expected2)
def test_gslib_to_vtk(): img = Image.fromGslib("tests/data/test_img.gslib") img.exportAsVtk("tests/data/test_img.vtk") img2 = img.fromVtk("tests/data/test_img.vtk") assert np.alltrue(img == img2)
def test_conversion_txt_gslib(): img = Image.fromTxt("tests/data/test_img.txt", (3, 3)) img.exportAsGslib("tests/data/test_img.gslib") img_test = Image.fromGslib("tests/data/test_img.gslib") assert np.alltrue(img_test == img)
def test_gslib_io(): img = Image.fromGslib("tests/data/test_color_simple.gslib") img.exportAsGslib("tests/data/test_color_simple2.gslib") img = Image.fromGslib("tests/data/test_color_simple.gslib") img2 = Image.fromGslib("tests/data/test_color_simple2.gslib") assert(img == img2)
parser = argparse.ArgumentParser() parser.add_argument("-fun", "--fun", type=str, required=True) parser.add_argument('-model', "--model", type=str, required=True) parser.add_argument('-ti', "--ti", type=str, required=True) parser.add_argument('-output', "--output", type=str, default="output.csv") parser.add_argument("-n-samples", "--n-samples", type=int, default=100) parser.add_argument("-n-ti", "--n-ti", type=int, default=100) args = parser.parse_args() model = GAN(args.model) if ".vox" in args.ti: ti = Image.fromVox(args.ti) elif ".gslib" in args.ti: ti = Image.fromGslib(args.ti) ti.threshold(thresholds=[1], values=[0, 1]) ti = ti.asArray() if args.fun == "conn": stat_fun = mpstool.connectivity.get_function elif args.fun == "vario": stat_fun = mpstool.stats.variogram else: raise Exception( "argument -fun not recognized. Should be 'conn' or 'vario' ") # Read connectivity for the TI : min and max of values cX_ti = [] cY_ti = []