-
Notifications
You must be signed in to change notification settings - Fork 22
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
MultiMacenkoNormalizer #57
Comments
Just merged here https://github.com/EIDOSLAB/torchstain/blob/main/torchstain/torch/normalizers/multitarget.py should work with torch :) |
@carloalbertobarbano Unfortunately, there seems to be a bug making it challenging for me to use it. I opened a PR to make it working, at least similarly to the other methods. See PR #64. |
Should be fixed in the development branch in commit 7c2a95f you should be able to install it with
Example usage: target = cv2.resize(cv2.cvtColor(cv2.imread(os.path.join(curr_file_path, "../data/target.png")), cv2.COLOR_BGR2RGB), (size, size))
to_transform = cv2.resize(cv2.cvtColor(cv2.imread(os.path.join(curr_file_path, "../data/source.png")), cv2.COLOR_BGR2RGB), (size, size))
# setup preprocessing and preprocess image to be normalized
T = transforms.Compose([
transforms.ToTensor(),
transforms.Lambda(lambda x: x * 255)
])
target = T(target)
t_to_transform = T(to_transform)
multi_normalizer = torchstain.normalizers.MultiMacenkoNormalizer(backend="torch", norm_mode="avg-post")
multi_normalizer.fit([target, target, target])
result_multi, _, _ = multi_normalizer.normalize(I=t_to_transform, stains=True) of course instead of [target, target, target] you are supposed to open multiple reference images |
@carloalbertobarbano Oh, this Why don't we just do I argue that it should be as easy as possible for the user to use this method, and that it should follow the same API, as much as possible, for all normalizers. |
Because it is supposed to work with multiple different reference images, so .fit should take an array |
Aaah, makes sense. Thanks for the clarification. But then after this is merged, I will make a PR to extend this to the different backends, and add the appropriate tests. |
@carloalbertobarbano Created PR #66 to add support for the missing NumPy and TensorFlow backends :] Seems to work! At least new tests pass, indicating that we reach the same result as for PyTorch backend. |
Hi,
I came across the following reference to MultiMacenkoNormalizer in the paper "MULTI-TARGET STAIN NORMALIZATION FOR HISTOLOGY SLIDES":
Could you please direct me to the location of the implementation of the MultiMacenkoNormalizer class within the repository? I would appreciate any guidance on where I can find the corresponding code.
Thank you!
The text was updated successfully, but these errors were encountered: