EIDOSLAB / torchstain

Stain normalization tools for histological analysis and computational pathology
MIT License
111 stars 20 forks source link

Support for Reinhard #24

Closed andreped closed 1 year ago

andreped commented 1 year ago

Reinhard color normalization is a commonly used method which is much faster than macenko and vahadane (see here). A drawback is that it is not as suitable for normalizing high-resolution patches, where the alternative methods are far superior.

However, for normalizing low-resolution images, reinhard might be more suitable. Hence, it would have been beneficial to have support for it.

It is also a very simple method to implement. I can make an attempt.

andreped commented 1 year ago

I made a PR which adds reinhard support with numpy backend: https://github.com/EIDOSLAB/torchstain/pull/25

Regarding the other backends, it would be beneficial to use tensorflow-io, as it supports both rgb2lab and lab2rgb, which was annoying to implement from scratch in numpy: https://www.tensorflow.org/io/api_docs/python/tfio/experimental/color/rgb_to_lab

In pytorch there exists a library that have the same color conversion methods: https://github.com/richzhang/colorization-pytorch/blob/66a1cb2e5258f7c8f374f582acc8b1ef99c13c27/util/util.py#L172

We could either use these libraries directly, or make our own implementations, but this will take time, but I could make an attempt. Will make a separate PR for that, as it will likely be a lot of work.

The reinhard transform itself is quite straight forward to implement.

andreped commented 1 year ago

New PR which adds torch backend support: https://github.com/EIDOSLAB/torchstain/pull/27

Now all backends should be supported after it has been merged. Hence, closing this issue.