From c94aa7d05886d53f500d6e74de620bafee38c790 Mon Sep 17 00:00:00 2001 From: ashmeigh Date: Mon, 11 Mar 2024 17:05:42 +0000 Subject: [PATCH 1/4] compute operation --- mantidimaging/core/operations/rescale/rescale.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/mantidimaging/core/operations/rescale/rescale.py b/mantidimaging/core/operations/rescale/rescale.py index 1e4696499cf..411ab8c951e 100644 --- a/mantidimaging/core/operations/rescale/rescale.py +++ b/mantidimaging/core/operations/rescale/rescale.py @@ -6,7 +6,7 @@ from typing import Any, Dict, TYPE_CHECKING import numpy as np - +from mantidimaging.core.parallel import shared as ps from mantidimaging.core.operations.base_filter import BaseFilter from mantidimaging.gui.utility.qt_helpers import Type @@ -42,9 +42,15 @@ def filter_func(images: ImageStack, :return: The ImageStack object scaled to a new range. """ - RescaleFilter.filter_array(images.data, min_input, max_input, max_output) + params = {'min_input': min_input, 'max_input': max_input, 'max_output': max_output} + ps.run_compute_func(RescaleFilter.compute_function, len(images.data), images.data, params) return images + @staticmethod + def compute_function(index: int, array: np.ndarray, params: dict): + min_input, max_input, max_output = params['min_input'], params['max_input'], params['max_output'] + array[index] = np.interp(array[index], [min_input, max_input], [0, max_output]) + @staticmethod def filter_array(image: np.ndarray, min_input: float, max_input: float, max_output: float) -> np.ndarray: image[:] = np.interp(image, [min_input, max_input], [0, max_output]) From 897c297972342941db99663c316f9fcd7e82473a Mon Sep 17 00:00:00 2001 From: ashmeigh Date: Tue, 12 Mar 2024 13:25:45 +0000 Subject: [PATCH 2/4] compute operation --- mantidimaging/core/operations/rescale/rescale.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mantidimaging/core/operations/rescale/rescale.py b/mantidimaging/core/operations/rescale/rescale.py index 411ab8c951e..d800b76d0cf 100644 --- a/mantidimaging/core/operations/rescale/rescale.py +++ b/mantidimaging/core/operations/rescale/rescale.py @@ -43,7 +43,8 @@ def filter_func(images: ImageStack, """ params = {'min_input': min_input, 'max_input': max_input, 'max_output': max_output} - ps.run_compute_func(RescaleFilter.compute_function, len(images.data), images.data, params) + ps.run_compute_func(RescaleFilter.compute_function, len(images.data), [images.shared_array], + params) # Pass 'params' here return images @staticmethod From 220341aef7a295393cd951ebbe77ab77fde99bfe Mon Sep 17 00:00:00 2001 From: ashmeigh Date: Tue, 12 Mar 2024 15:07:43 +0000 Subject: [PATCH 3/4] compute operation --- mantidimaging/core/operations/rescale/rescale.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mantidimaging/core/operations/rescale/rescale.py b/mantidimaging/core/operations/rescale/rescale.py index d800b76d0cf..185bbb8019d 100644 --- a/mantidimaging/core/operations/rescale/rescale.py +++ b/mantidimaging/core/operations/rescale/rescale.py @@ -43,8 +43,7 @@ def filter_func(images: ImageStack, """ params = {'min_input': min_input, 'max_input': max_input, 'max_output': max_output} - ps.run_compute_func(RescaleFilter.compute_function, len(images.data), [images.shared_array], - params) # Pass 'params' here + ps.run_compute_func(RescaleFilter.compute_function, len(images.data), [images.shared_array], params) return images @staticmethod From 0d4604febc7368e3ce713fb68a02b9243ee8bb87 Mon Sep 17 00:00:00 2001 From: ashmeigh Date: Wed, 13 Mar 2024 07:59:38 +0000 Subject: [PATCH 4/4] compute operation --- mantidimaging/core/operations/rescale/rescale.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mantidimaging/core/operations/rescale/rescale.py b/mantidimaging/core/operations/rescale/rescale.py index 185bbb8019d..91099c107d6 100644 --- a/mantidimaging/core/operations/rescale/rescale.py +++ b/mantidimaging/core/operations/rescale/rescale.py @@ -49,7 +49,7 @@ def filter_func(images: ImageStack, @staticmethod def compute_function(index: int, array: np.ndarray, params: dict): min_input, max_input, max_output = params['min_input'], params['max_input'], params['max_output'] - array[index] = np.interp(array[index], [min_input, max_input], [0, max_output]) + array[index] = RescaleFilter.filter_array(array[index], min_input, max_input, max_output) @staticmethod def filter_array(image: np.ndarray, min_input: float, max_input: float, max_output: float) -> np.ndarray: