Add SaveFig

This commit is contained in:
Florent Guiotte 2018-04-09 19:47:45 +02:00
parent 47b290a23d
commit 8705de77af
4 changed files with 42 additions and 7 deletions

View File

@ -12,6 +12,7 @@ from core import Filter
## TODO: dep ## TODO: dep
import sys import sys
import numpy as np
sys.path.append('../triskele/python') sys.path.append('../triskele/python')
import triskele import triskele
@ -31,4 +32,6 @@ class AttributeProfiles(Filter):
standard_deviation=self.sd, standard_deviation=self.sd,
moment_of_inertia=self.moi) moment_of_inertia=self.moi)
return att, None att = np.dstack((att_min, att_max))
return att, metadata

29
ld2dap/SaveFig.py Normal file
View File

@ -0,0 +1,29 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# \file SaveFig.py
# \brief TODO
# \author Florent Guiotte <florent.guiotte@gmail.com>
# \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)

View File

@ -17,7 +17,7 @@ class Node(object):
return ("Node:{}".format(self.name)) return ("Node:{}".format(self.name))
def process(self, data, metadata=None): def process(self, data, metadata=None):
self._process(data) self._process(data, metadata)
def _process(self, data, metadata=None): def _process(self, data, metadata=None):
raise NotImplementedError( raise NotImplementedError(

View File

@ -8,17 +8,20 @@
# #
# TODO details # TODO details
from core import Input, Output, Filter #from core import Input, Output, Filter
from LoadTIFF import LoadTIFF from LoadTIFF import LoadTIFF
from AttributeProfiles import AttributeProfiles as APs from AttributeProfiles import AttributeProfiles as APs
from SaveFig import SaveFig
import numpy as np
def main(): def main():
i = LoadTIFF(['../Data/test.tiff']) i = LoadTIFF(['../Data/test.tiff', '../Data/test.tiff'])
ap = APs() ap = APs(np.array([100,1e3,1e4]))
o = Output('o') o = SaveFig('test.png')
ap.input = i ap.input = i
o.input = i o.input = ap
o.run() o.run()