Skip to content

Commit

Permalink
Replace masked_images_dict with create_masked_images_dict
Browse files Browse the repository at this point in the history
The default behavior of create_masked_images_dict is the same as
masked_images_dict, but with the additional option to set the fill value for
the mask. If the fill type and mask type do not match the image will be cast to
the correct type.

Signed-off-by: Brianna Major <[email protected]>
  • Loading branch information
bnmajor committed Oct 10, 2023
1 parent bae82d7 commit 9a2bfc9
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions hexrd/ui/hexrd_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -890,14 +890,18 @@ def raw_masks_dict(self):

return masks_dict

@property
def masked_images_dict(self):
def create_masked_images_dict(self, fill_value=0):
"""Get an images dict where masks have been applied"""
images_dict = self.images_dict
have_masks = len(self.visible_masks)
for det, mask in self.raw_masks_dict.items():
for name, img in images_dict.items():
if (have_masks and
np.issubdtype(type(fill_value), np.floating) and
not np.issubdtype(img.dtype, np.floating)):
img = img.astype(float)
if det == name:
img[~mask] = 0
img[~mask] = fill_value

return images_dict

Expand Down

0 comments on commit 9a2bfc9

Please sign in to comment.