Skip to content

Fix stain normalizer float dtype detection#1109

Open
fallintoplace wants to merge 1 commit into
rapidsai:mainfrom
fallintoplace:fix/stain-normalizer-float-dtype
Open

Fix stain normalizer float dtype detection#1109
fallintoplace wants to merge 1 commit into
rapidsai:mainfrom
fallintoplace:fix/stain-normalizer-float-dtype

Conversation

@fallintoplace

Copy link
Copy Markdown

Summary

Fix float input detection in image_to_absorbance so normalized floating-point images use the float clipping path.

What changed

  • detect float inputs with image.dtype.kind == "f" instead of comparing the dtype object to the string "f"
  • add regression coverage for float32 and float64 inputs in test_stain_normalizer.py
  • validate the normalized-float case with source_intensity=1.0, including lower-bound and upper-bound clipping

Why

image_to_absorbance receives image.dtype as a dtype object, so the old input_dtype == "f" check was always false.

That sent float images through the integer clipping path. For normalized inputs, especially with source_intensity=1.0, values below 1.0 were clipped incorrectly before the absorbance transform.

Validation

  • reviewed the float/int clipping logic in stain_normalizer.py
  • added direct unit coverage for image_to_absorbance with float32 and float64 inputs
  • ran python3 -m py_compile on the changed source and test files
  • could not run the Python unit tests locally because this machine does not have cupy installed

@fallintoplace fallintoplace requested a review from a team as a code owner June 27, 2026 21:09
@copy-pr-bot

copy-pr-bot Bot commented Jun 27, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant