diff --git a/ld2dap/AttributeProfiles.py b/ld2dap/AttributeProfiles.py index c8551cf..402907c 100644 --- a/ld2dap/AttributeProfiles.py +++ b/ld2dap/AttributeProfiles.py @@ -12,6 +12,7 @@ from core import Filter ## TODO: dep import sys +import numpy as np sys.path.append('../triskele/python') import triskele @@ -31,4 +32,6 @@ class AttributeProfiles(Filter): standard_deviation=self.sd, moment_of_inertia=self.moi) - return att, None + att = np.dstack((att_min, att_max)) + + return att, metadata diff --git a/ld2dap/SaveFig.py b/ld2dap/SaveFig.py new file mode 100644 index 0000000..9d72e50 --- /dev/null +++ b/ld2dap/SaveFig.py @@ -0,0 +1,29 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# \file SaveFig.py +# \brief TODO +# \author Florent Guiotte +# \version 0.1 +# \date 09 avril 2018 +# +# TODO details + +from core import Output + +import matplotlib.pyplot as plt + +class SaveFig(Output): + def __init__(self, fname, bbox_inches='tight', pad_inches=1): + super().__init__(self.__class__.__name__) + self.fname = fname + self.bbox_inches = bbox_inches + self.pad_inches = pad_inches + + def _process(self, data, metadata): + im_size = 2 + plt.figure(figsize=(16*im_size,3*im_size)) + plt.imshow(data[:,:,-1]) + plt.colorbar() + if metadata is not None: + plt.title(metadata[-1]) + plt.savefig(self.fname, bbox_inches=self.bbox_inches, pad_inches=self.pad_inches) diff --git a/ld2dap/core/Node.py b/ld2dap/core/Node.py index 1a6ca27..3af0305 100644 --- a/ld2dap/core/Node.py +++ b/ld2dap/core/Node.py @@ -17,7 +17,7 @@ class Node(object): return ("Node:{}".format(self.name)) def process(self, data, metadata=None): - self._process(data) + self._process(data, metadata) def _process(self, data, metadata=None): raise NotImplementedError( diff --git a/ld2dap/test.py b/ld2dap/test.py index 1e3fbed..6769ceb 100644 --- a/ld2dap/test.py +++ b/ld2dap/test.py @@ -8,17 +8,20 @@ # # TODO details -from core import Input, Output, Filter +#from core import Input, Output, Filter from LoadTIFF import LoadTIFF from AttributeProfiles import AttributeProfiles as APs +from SaveFig import SaveFig + +import numpy as np def main(): - i = LoadTIFF(['../Data/test.tiff']) - ap = APs() - o = Output('o') + i = LoadTIFF(['../Data/test.tiff', '../Data/test.tiff']) + ap = APs(np.array([100,1e3,1e4])) + o = SaveFig('test.png') ap.input = i - o.input = i + o.input = ap o.run()