Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add reinhard color normalization support #25

Merged
merged 22 commits into from
Dec 2, 2022

Conversation

andreped
Copy link
Collaborator

@andreped andreped commented Nov 23, 2022

I have added support for reinhard color normalization, as an alternative to Macenko, as discussed in #24.

Reinhard itself was straight forward to implement, but I had a hard time getting the RGB/LAB color converters to work as intended. After looking at what OpenCV, Scikit-Image, and other projects were doing, I managed to implement numpy-equivalents. In the end, from qualitative assessment, I get the same results as another commonly used library, StainTools.

Have not had the time to benchmark it yet, hence, experimental, but at least it runs and serves as an alternative method.

UPDATE: Now both Numpy and TensorFlow backends are supported!

What's changed:

  • Added ReinhardNormalizer - currently supports both numpy and tensorflow backends.
  • Added rgb2lab and lab2rgb color conversion implementations.
  • Added convenience functions relevant to Reinhard in stats and split.
  • Updated README regarding experimental Reinhard support with reference to original article.
  • Added RGB->LAB->RGB unit test (currently fails - focused on getting it to work with Reinhard and not in the general case).
  • Moved result.pngto data/directory and updated corresponding path in README.
  • Minor README refactoring.

@andreped andreped changed the title Add reinhard color normalization support (numpy) Add reinhard color normalization support Nov 24, 2022
@andreped
Copy link
Collaborator Author

Note that I also added TF support now, as I need it for one of my studied.

Will not have time for PyTorch any time soon, but at least both Numpy and TF backends work as intended.

@carloalbertobarbano
Copy link
Member

Thanks for the contribution! Merging it now

@carloalbertobarbano carloalbertobarbano merged commit 8b02b9f into EIDOSLAB:main Dec 2, 2022
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.

2 participants