Skip to content
Snippets Groups Projects
Commit d2fca993 authored by Frisinghelli Daniel's avatar Frisinghelli Daniel
Browse files

Added batch scripts to produces plots for thesis.

parent 5c0df091
No related branches found
No related tags found
No related merge requests found
"""Plot the distribution of the classes of a dataset in spectral space.
License
-------
Copyright (c) 2020 Daniel Frisinghelli
This source code is licensed under the GNU General Public License v3.
See the LICENSE file in the repository's root directory.
"""
# !/usr/bin/env python
# -*- coding: utf-8 -*-
# builtins
from logging.config import dictConfig
# locals
from pysegcnn.core.trainer import DatasetConfig
from pysegcnn.core.graphics import plot_class_distribution
from pysegcnn.core.logging import log_conf
from pysegcnn.plot.plot_config import (PLOT_PATH, BANDS, FIGSIZE, ALPHA,
DATASETS, DPI)
if __name__ == '__main__':
# initialize logging
dictConfig(log_conf())
# iterate over the datasets
for name, params in DATASETS.items():
# instanciate dataset
dc = DatasetConfig(dataset_name=name, bands=BANDS, tile_size=None,
**params)
ds = dc.init_dataset()
# plot class distribution
fig = plot_class_distribution(ds, FIGSIZE, ALPHA)
# save figure
filename = PLOT_PATH.joinpath('{}_sdist.png'.format(name))
fig.savefig(filename, dpi=DPI, bbox_inches='tight')
"""Plot a false color composite of each scene in a dataset.
License
-------
Copyright (c) 2020 Daniel Frisinghelli
This source code is licensed under the GNU General Public License v3.
See the LICENSE file in the repository's root directory.
"""
# !/usr/bin/env python
# -*- coding: utf-8 -*-
# builtins
import logging
from logging.config import dictConfig
# locals
from pysegcnn.core.trainer import DatasetConfig
from pysegcnn.core.graphics import plot_sample
from pysegcnn.core.logging import log_conf
from pysegcnn.plot.plot_config import (PLOT_PATH, BANDS, FIGSIZE, ALPHA,
DATASETS, PLOT_BANDS, DPI)
# module level logger
LOGGER = logging.getLogger(__name__)
if __name__ == '__main__':
# initialize logging
dictConfig(log_conf())
# iterate over the datasets
for name, params in DATASETS.items():
# instanciate dataset
dc = DatasetConfig(dataset_name=name, bands=BANDS, tile_size=None,
**params)
ds = dc.init_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']
LOGGER.info(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=PLOT_BANDS,
alpha=ALPHA, figsize=FIGSIZE)
# save the figure
fig.savefig(PLOT_PATH.joinpath('.'.join([scene_id, 'png'])),
dpi=DPI, bbox_inches='tight')
"""Configuration file for plotting.
License
-------
Copyright (c) 2020 Daniel Frisinghelli
This source code is licensed under the GNU General Public License v3.
See the LICENSE file in the repository's root directory.
"""
# !/usr/bin/env python
# -*- coding: utf-8 -*-
# builtins
import pathlib
# path to this file
HERE = pathlib.Path(__file__).resolve().parent
# path to save plots
PLOT_PATH = HERE.joinpath('_plots/')
# check if the output path exists
if not PLOT_PATH.exists():
PLOT_PATH.mkdir()
# path to the datasets on the current machine
# DRIVE_PATH = pathlib.Path('C:/Eurac/Projects/CCISNOW/Datasets/')
DRIVE_PATH = pathlib.Path('F:/Studium/SS 2020/Datasets/')
# name and paths to the datasets
DATASETS = {'Sparcs': {'root_dir': DRIVE_PATH.joinpath('Sparcs'),
'merge_labels': {'Shadow_over_water': 'Shadow',
'Flooded': 'Land'},
'gt_pattern': '(.*)mask\\.png'},
'Alcd': {'root_dir': DRIVE_PATH.joinpath('Alcd/Resampled/20m'),
'merge_labels': {'Cirrus': 'Cloud',
'Not_used': 'No_data'},
'gt_pattern': '(.*)Labels\\.tif'}
}
# spectral bands to plot distribution
BANDS = ['aerosol', 'blue', 'green', 'red', 'nir', 'cirrus', 'swir1', 'swir2']
# plot parameters
FIGSIZE = (16, 9)
ALPHA = 0.5
DPI = 300
# natural with atmospheric removal
PLOT_BANDS = ['swir2', 'nir', 'green']
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment