|
import argparse |
|
|
|
import numpy as np |
|
import matplotlib.pyplot as plt |
|
|
|
from frame_field_learning import plot_utils |
|
|
|
|
|
def get_args(): |
|
argparser = argparse.ArgumentParser(description=__doc__) |
|
argparser.add_argument( |
|
'-f', '--filepath', |
|
required=True, |
|
type=str, |
|
help='Path to the .npy to plot the framefield from.') |
|
argparser.add_argument( |
|
'-o', '--out_filepath', |
|
required=True, |
|
type=str, |
|
help='Path to save the image.') |
|
|
|
args = argparser.parse_args() |
|
return args |
|
|
|
|
|
def save_plot_framefield(framefield, out_filepath): |
|
|
|
height = framefield.shape[0] |
|
width = framefield.shape[1] |
|
f, axis = plt.subplots(1, 1, figsize=(width // 10, height // 10)) |
|
|
|
|
|
transparent_im = np.zeros((height, width, 4)) |
|
axis.imshow(transparent_im) |
|
|
|
framefield_stride = 8 |
|
plot_utils.plot_framefield(axis, framefield, framefield_stride, alpha=1, width=2) |
|
|
|
axis.autoscale(False) |
|
axis.axis('equal') |
|
axis.axis('off') |
|
|
|
|
|
plt.subplots_adjust(left=0, right=1, top=1, bottom=0) |
|
plt.savefig(out_filepath, transparent=True) |
|
plt.close() |
|
|
|
|
|
|
|
def main(): |
|
|
|
args = get_args() |
|
|
|
|
|
framefield = np.load(args.filepath) |
|
|
|
|
|
|
|
|
|
|
|
save_plot_framefield(framefield, args.out_filepath) |
|
|
|
|
|
if __name__ == '__main__': |
|
main() |
|
|