From e42e9539f7b6c016b2dc6abbbda2814bb66389b8 Mon Sep 17 00:00:00 2001 From: "Daniel.Frisinghelli" <daniel.frisinghelli@eurac.edu> Date: Fri, 8 Jan 2021 15:37:35 +0100 Subject: [PATCH] Added a function to plot each scene of a dataset. --- pysegcnn/core/graphics.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/pysegcnn/core/graphics.py b/pysegcnn/core/graphics.py index ede4c84..3143486 100644 --- a/pysegcnn/core/graphics.py +++ b/pysegcnn/core/graphics.py @@ -706,3 +706,24 @@ class Animate(object): # save animation to disk self.animation.save(str(self.path.joinpath(filename)), writer='imagemagick', **kwargs) + + +def _plot_composites(ds, path, fmt, dpi=300, alpha=0): + """Utility function to plot each scene of a dataset.""" + + # iterate over the scenes of the dataset + for scene in range(len(ds)): + # name of the current scene + scene_id = ds.scenes[scene]['id'] + print(scene_id) + + # get the data of the current scene + x, y = ds[scene] + + # plot the current scene + fig = plot_sample(x, ds.use_bands, ds.labels, y=y, hide_labels=True, + bands=['swir2', 'nir', 'green'], alpha=alpha) + + # save the figure as vector graphic + fig.savefig(path.joinpath(scene_id + '.{}'.format(fmt)), dpi=dpi, + bbox_inches='tight', format=fmt) -- GitLab