Skip to content

Commit 8006ae1

Browse files
authored
Merge pull request #1156 from MouseLand/blank_channel
zero out channels that aren't normazlied
2 parents 636f0ee + 6327d3a commit 8006ae1

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

cellpose/transforms.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -746,6 +746,14 @@ def normalize_img(img, normalize=True, norm3D=True, invert=False, lowhigh=None,
746746
if axis != -1 and axis != img_norm.ndim - 1:
747747
img_norm = np.moveaxis(img_norm, -1, axis)
748748

749+
# The transformer can get confused if a channel is all 1's instead of all 0's:
750+
for i, chan_did_normalize in enumerate(cgood):
751+
if not chan_did_normalize:
752+
if img_norm.ndim == 3:
753+
img_norm[:, :, i] = 0
754+
if img_norm.ndim == 4:
755+
img_norm[0, :, :, i] = 0
756+
749757
return img_norm
750758

751759
def resize_safe(img, Ly, Lx, interpolation=cv2.INTER_LINEAR):

0 commit comments

Comments
 (0)