Skip to content

Commit 4149f51

Browse files
committed
move reordering axes to after image normalization
1 parent cc9d63f commit 4149f51

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

cellpose/transforms.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -776,10 +776,6 @@ def normalize_img(img, normalize=True, norm3D=True, invert=False, lowhigh=None,
776776
transforms_logger.critical(error_message)
777777
raise ValueError(error_message)
778778

779-
# Move channel axis back to the original position
780-
if axis != -1 and axis != img_norm.ndim - 1:
781-
img_norm = np.moveaxis(img_norm, -1, axis)
782-
783779
# The transformer can get confused if a channel is all 1's instead of all 0's:
784780
for i, chan_did_normalize in enumerate(cgood):
785781
if not chan_did_normalize:
@@ -788,6 +784,10 @@ def normalize_img(img, normalize=True, norm3D=True, invert=False, lowhigh=None,
788784
if img_norm.ndim == 4:
789785
img_norm[:, :, :, i] = 0
790786

787+
# Move channel axis back to the original position
788+
if axis != -1 and axis != img_norm.ndim - 1:
789+
img_norm = np.moveaxis(img_norm, -1, axis)
790+
791791
return img_norm
792792

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

0 commit comments

Comments
 (0)