Skip to content

Commit

Permalink
Memoize median filter results for FIDDLE
Browse files Browse the repository at this point in the history
This takes up about ~200 MB to contain the results for all 21 FIDDLE
images. We may want to multi-thread across images as well...

Signed-off-by: Patrick Avery <[email protected]>
  • Loading branch information
psavery committed Dec 18, 2024
1 parent 0bd8bfb commit b835a98
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion hexrdgui/hexrd_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from hexrd.instrument.physics_package import HEDPhysicsPackage
from hexrd.material import load_materials_hdf5, save_materials_hdf5, Material
from hexrd.rotations import RotMatEuler
from hexrd.utils.decorators import memoize
from hexrd.utils.yaml import NumpyToNativeDumper
from hexrd.valunits import valWUnit

Expand Down Expand Up @@ -1004,7 +1005,7 @@ def intensity_corrected_images_dict(self):

if HexrdConfig().apply_median_filter_correction:
for name, img in images_dict.items():
images_dict[name] = medfilt2d(
images_dict[name] = medfilt2d_memoized(
img,
kernel_size=HexrdConfig().median_filter_kernel_size
)
Expand Down Expand Up @@ -3179,3 +3180,10 @@ def median_filter_kernel_size(self, v):
if v != self.median_filter_kernel_size:
self._median_filer_correction['kernel'] = v
self.deep_rerender_needed.emit()


# This is set to (num_fiddle_plates * num_time_steps) + num_image_plates
# This feature is primarily for FIDDLE
@memoize(maxsize=21)
def medfilt2d_memoized(img: np.ndarray, kernel_size: int):
return medfilt2d(img, kernel_size)

0 comments on commit b835a98

Please sign in to comment.