Matplotlib is garbage
This commit is contained in:
parent
8705de77af
commit
7689382a64
@ -21,9 +21,11 @@ class SaveFig(Output):
|
||||
|
||||
def _process(self, data, metadata):
|
||||
im_size = 2
|
||||
plt.figure(figsize=(16*im_size,3*im_size))
|
||||
plt.imshow(data[:,:,-1])
|
||||
plt.colorbar()
|
||||
fig = plt.figure(figsize=(16*im_size,3*im_size))
|
||||
f1 = fig.add_subplot(111)
|
||||
img = f1.imshow(data[:,:,-1])
|
||||
plt.colorbar(img)
|
||||
if metadata is not None:
|
||||
plt.title(metadata[-1])
|
||||
plt.savefig(self.fname, bbox_inches=self.bbox_inches, pad_inches=self.pad_inches)
|
||||
f1.set_title(metadata[-1])
|
||||
fig.savefig(self.fname, bbox_inches=self.bbox_inches, pad_inches=self.pad_inches)
|
||||
plt.close(fig)
|
||||
|
||||
31
ld2dap/ShowFig.py
Normal file
31
ld2dap/ShowFig.py
Normal file
@ -0,0 +1,31 @@
|
||||
#!/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 ShowFig(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
|
||||
fig = plt.figure(figsize=(16*im_size,3*im_size))
|
||||
f1 = fig.add_subplot(111)
|
||||
img = f1.imshow(data[:,:,-1])
|
||||
plt.colorbar(img)
|
||||
if metadata is not None:
|
||||
f1.set_title(metadata[-1])
|
||||
plt.show()
|
||||
plt.close(fig)
|
||||
23
ld2dap/Treshold.py
Normal file
23
ld2dap/Treshold.py
Normal file
@ -0,0 +1,23 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
# \file Treshold.py
|
||||
# \brief TODO
|
||||
# \author Florent Guiotte <florent.guiotte@gmail.com>
|
||||
# \version 0.1
|
||||
# \date 09 avril 2018
|
||||
#
|
||||
# TODO details
|
||||
|
||||
from core import Filter
|
||||
|
||||
class Treshold(Filter):
|
||||
def __init__(self, treshold, max_value=None):
|
||||
super().__init__(self.__class__.__name__)
|
||||
self.treshold = treshold
|
||||
self.max_value = max_value #if max_value is not None else treshold
|
||||
|
||||
def _process(self, data, metadata):
|
||||
if self.max_value is None:
|
||||
self.max_value = data[data < self.treshold].max()
|
||||
|
||||
return data * (data < self.treshold) + self.max_value * (data >= self.treshold), metadata
|
||||
@ -12,18 +12,24 @@
|
||||
from LoadTIFF import LoadTIFF
|
||||
from AttributeProfiles import AttributeProfiles as APs
|
||||
from SaveFig import SaveFig
|
||||
from Treshold import Treshold
|
||||
from ShowFig import ShowFig
|
||||
|
||||
import numpy as np
|
||||
|
||||
def main():
|
||||
i = LoadTIFF(['../Data/test.tiff', '../Data/test.tiff'])
|
||||
t = Treshold(1e4)
|
||||
ap = APs(np.array([100,1e3,1e4]))
|
||||
o = SaveFig('test.png')
|
||||
s = ShowFig(None)
|
||||
|
||||
ap.input = i
|
||||
t.input = i
|
||||
ap.input = t
|
||||
o.input = ap
|
||||
s.input = ap
|
||||
|
||||
o.run()
|
||||
i.run()
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user