diff options
author | epapoutsellis <epapoutsellis@gmail.com> | 2019-06-03 22:50:21 +0100 |
---|---|---|
committer | epapoutsellis <epapoutsellis@gmail.com> | 2019-06-03 22:50:21 +0100 |
commit | c9f7f66da692d5ec8d5927775dbff3ac3aeb8c7c (patch) | |
tree | 3fa81adf056b0983b31f9c79c14e99e7da6b7ffd | |
parent | c7ed6d4cf69029311dade3811cd574772f4879a5 (diff) | |
download | framework-c9f7f66da692d5ec8d5927775dbff3ac3aeb8c7c.tar.gz framework-c9f7f66da692d5ec8d5927775dbff3ac3aeb8c7c.tar.bz2 framework-c9f7f66da692d5ec8d5927775dbff3ac3aeb8c7c.tar.xz framework-c9f7f66da692d5ec8d5927775dbff3ac3aeb8c7c.zip |
add nice phantom
-rwxr-xr-x | Wrappers/Python/ccpi/framework/TestData.py | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/Wrappers/Python/ccpi/framework/TestData.py b/Wrappers/Python/ccpi/framework/TestData.py index 752bc13..cfad7a3 100755 --- a/Wrappers/Python/ccpi/framework/TestData.py +++ b/Wrappers/Python/ccpi/framework/TestData.py @@ -16,6 +16,7 @@ class TestData(object): PEPPERS = 'peppers.tiff'
RESOLUTION_CHART = 'resolution_chart.tiff'
SIMPLE_PHANTOM_2D = 'simple_jakobs_phantom'
+ SHAPES = 'shapes.png'
def __init__(self, **kwargs):
self.data_dir = kwargs.get('data_dir', data_dir)
@@ -23,7 +24,7 @@ class TestData(object): def load(self, which, size=(512,512), scale=(0,1), **kwargs):
if which not in [TestData.BOAT, TestData.CAMERA,
TestData.PEPPERS, TestData.RESOLUTION_CHART,
- TestData.SIMPLE_PHANTOM_2D]:
+ TestData.SIMPLE_PHANTOM_2D, TestData.SHAPES]:
raise ValueError('Unknown TestData {}.'.format(which))
if which == TestData.SIMPLE_PHANTOM_2D:
N = size[0]
@@ -34,6 +35,16 @@ class TestData(object): ig = ImageGeometry(voxel_num_x = N, voxel_num_y = M, dimension_labels=[ImageGeometry.HORIZONTAL_X, ImageGeometry.HORIZONTAL_Y])
data = ig.allocate()
data.fill(sdata)
+
+ elif which == TestData.SHAPES:
+
+ tmp = numpy.array(Image.open(os.path.join(self.data_dir, which)).convert('L'))
+ N = 200
+ M = 300
+ ig = ImageGeometry(voxel_num_x = N, voxel_num_y = M, dimension_labels=[ImageGeometry.HORIZONTAL_X, ImageGeometry.HORIZONTAL_Y])
+ data = ig.allocate()
+ data.fill(tmp/numpy.max(tmp))
+
else:
tmp = Image.open(os.path.join(self.data_dir, which))
print (tmp)
@@ -94,5 +105,17 @@ class TestData(object): data = data/data.max()
- return ImageData(data)
+ return ImageData(data)
+
+ def shapes(**kwargs):
+
+ tmp = Image.open(os.path.join(data_dir, 'shapes.png')).convert('LA')
+
+ size = kwargs.get('size',(300, 200))
+
+ data = numpy.array(tmp.resize(size))
+
+ data = data/data.max()
+
+ return ImageData(data)
|