From 5dc6c87fa37f881164f58dd355dfaefc137e139b Mon Sep 17 00:00:00 2001 From: Jakub Both Date: Mon, 24 Jun 2024 14:36:25 +0200 Subject: [PATCH] BUG: Invoke the right image type --- src/darsia/utils/standard_images.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/darsia/utils/standard_images.py b/src/darsia/utils/standard_images.py index ac5ce4c9..a33a73e3 100644 --- a/src/darsia/utils/standard_images.py +++ b/src/darsia/utils/standard_images.py @@ -29,9 +29,10 @@ def zeros_like( if dtype is None: dtype = image.dtype if mode == "shape": - return darsia.Image(np.zeros(image.shape, dtype=dtype), metadata=image.metadata) + ImageType = type(image) + return ImageType(np.zeros(image.shape, dtype=dtype), metadata=image.metadata) elif mode == "voxels": - return darsia.Image( + return darsia.ScalarImage( np.zeros(image.num_voxels, dtype=dtype), metadata=image.metadata ) @@ -56,8 +57,9 @@ def ones_like( if dtype is None: dtype = image.dtype if mode == "shape": - return darsia.Image(np.ones(image.shape, dtype=dtype), metadata=image.metadata) + ImageType = type(image) + return ImageType(np.ones(image.shape, dtype=dtype), metadata=image.metadata) elif mode == "voxels": - return darsia.Image( + return darsia.ScalarImage( np.ones(image.num_voxels, dtype=dtype), metadata=image.metadata )