Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compute rescale operation #2130

Merged
merged 4 commits into from
Mar 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions mantidimaging/core/operations/rescale/rescale.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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.shared_array], 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] = 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:
image[:] = np.interp(image, [min_input, max_input], [0, max_output])
Expand Down
Loading