Skip to content

Commit

Permalink
Fix cv2_downscale_local_mean call
Browse files Browse the repository at this point in the history
  • Loading branch information
Yu-AnChen committed May 18, 2023
1 parent 6683ce2 commit 2b983ad
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions palom/img_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,11 @@ def entropy_mask(img, kernel_size=9):
def is_brightfield_img(img, max_size=100):
img = np.array(img)
downscale_factor = int(max(img.shape) / max_size)
thumbnail = cv2_downscale_local_mean(img, (downscale_factor, downscale_factor))
mask = entropy_mask(thumbnail)
if downscale_factor > 1:
img = cv2_downscale_local_mean(img, downscale_factor)
mask = entropy_mask(img)
# is using mean better?
return np.median(thumbnail[mask]) < np.median(thumbnail[~mask])
return np.median(img[mask]) < np.median(img[~mask])


def block_labeled_mask(img_shape, block_shape, out_chunks=None):
Expand Down

0 comments on commit 2b983ad

Please sign in to comment.