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

Allow use of complex numbers with denoise_nl_means #5483

Closed
shirawerman opened this issue Jul 20, 2021 · 3 comments · Fixed by #5488
Closed

Allow use of complex numbers with denoise_nl_means #5483

shirawerman opened this issue Jul 20, 2021 · 3 comments · Fixed by #5488

Comments

@shirawerman
Copy link

The code of non_local_means.py converts the dataset to 'float', but I have a dataset with complex numbers. Is there a possibility to support more data types?

Thanks

@grlee77
Copy link
Contributor

grlee77 commented Jul 20, 2021

It would likely require substantial work to refactor the underlying Cython code to support complex types directly, but there are a couple of other options:

1.) Run non-local means independently on the real and imaginary components.

2.) If the data is 2D it might also be possible to stack the real and imaginary data along a new axis (e.g. np.stack((image.real, image.imag), axis=-1) and call it with multichannel=True. This would consider both components together when determining patch similarity and ensure that the same patch weights were used for both components. If your data is 3D, we would need to add support for 3D multichannel for this to work. but I do already have an implementation for that which I never officially submitted for review. Let me know if your data is 3D and I can see about reviving that.

@grlee77 grlee77 changed the title Allow complex numbers Allow use of complex numbers with denoise_nl_means Jul 20, 2021
@shirawerman
Copy link
Author

Thank you for the quick reply!
I am working on 3D data so if you can let me know when that code is ready, that would be great!
For now I will work with the first solution, although is will generate different weights for the real and imaginary part.

@grlee77
Copy link
Contributor

grlee77 commented Jul 22, 2021

Hi @shirawerman, I opened a PR for 3D+multichannel (and 4D) support in #5488. If you want to compile scikit-image from that branch you can try it out.

We are hoping to make a 0.19 release soon, but I don't know that the PR will be reviewed in time for that.

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

Successfully merging a pull request may close this issue.

2 participants