Skip to content

Commit

Permalink
Mask scale fix
Browse files Browse the repository at this point in the history
  • Loading branch information
KorenMary committed Jan 7, 2024
1 parent 39d9e7d commit 0488e8d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/server/dcp_server/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import numpy as np
from scipy.ndimage import find_objects, center_of_mass
from skimage import measure
from copy import deepcopy

def read_config(name, config_path = 'config.cfg') -> dict:
"""Reads the configuration file
Expand Down Expand Up @@ -72,6 +73,8 @@ def crop_centered_padded_patch(x: np.ndarray,
x[m] = 0
if noise_intensity is not None:
x[m] = np.random.normal(scale=noise_intensity, size=x[m].shape)
if mask is not None:
mask[m] = 0

patch = x[max(top, 0):min(bottom, x.shape[0]), max(left, 0):min(right, x.shape[1]), :]
if mask is not None:
Expand Down Expand Up @@ -177,9 +180,10 @@ def get_centered_patches(img,
(c_x, c_y),
(p_size, p_size),
l,
mask=mask,
mask=deepcopy(mask),
noise_intensity=noise_intensity)
if include_mask:
patch_mask = 255 * (patch_mask > 0).astype(np.uint8)
patch = np.concatenate((patch, patch_mask), axis=-1)


Expand Down
2 changes: 1 addition & 1 deletion src/server/test/test_config.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"in_channels": 1,
"num_classes": 3,
"black_bg": "False",
"include_mask": "False"
"include_mask": "True"
}
},

Expand Down

0 comments on commit 0488e8d

Please sign in to comment.