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

Question - DWT 3D Wavelet Coefficients Organization #84

Open
ktaswell opened this issue Jan 6, 2023 · 4 comments
Open

Question - DWT 3D Wavelet Coefficients Organization #84

ktaswell opened this issue Jan 6, 2023 · 4 comments

Comments

@ktaswell
Copy link

ktaswell commented Jan 6, 2023

I'm trying to implement a soft thresholding method for 3D data which preserves scaling (or approximation) coefficients at each level, then soft thresholds all others. Unfortunately, I have been having trouble identifying indices which correspond to the scaling coefficients. I was trying to make sense of the detailn() and detailindex() functions and it makes sense to me for 1D condition, but I don't understand how to use these to create an index list for higher dimensions, like the 3D condition that I need.

Also to complicate further, I need to handle both dyadic cube and dyadic non-cube dimensions.

Could someone help me with this?

Thanks

@ktaswell
Copy link
Author

ktaswell commented Jan 7, 2023

After working with it some more, I think I actually may have had it correct the first time around while working on it a couple weeks ago and simply had a "wait did I mess up moment". I'll put my notes here for others to confirm/check:

When not specifying a level to transform to, Wavelets.jl automatically transforms up to maximum level.

  • For the case of $n \times n \times n$ , where $n=2^k$ is dyadic, dwt function decomposes to max level $k$ leaving only 1 approximation coefficient in [1, 1, 1] position as the only remaining value with the detail coefficients for level $k$ in positions of index greater than 2 in each dimension.

  • For the case of $n\times n\times m$, where $n = 2^k, m = 2^j$ with $k < j$, dwt function decomposes to max level $k$ again, however this time having $b=m/n = 2^{j-k}$ approximation coefficients, stored along the 3rd dimension which has the longest length. Making approximation coefficients stored in positions [1, 1, 1:b] and level $k$ detail coefficients stored in positions greater than 2 in dims 1 and 2, while positions greater than $b$, for dim 3.

If I have the right thinking here, please let me know.

@JeffFessler
Copy link
Contributor

I have a 2D example here that might help:
https://juliaimagerecon.github.io/Examples/generated/mri/2-cs-wl-l1-2d/
which uses this code:
https://github.com/JeffFessler/MIRT.jl/blob/main/src/regularize/Aodwt.jl
I did not know about or use detailn or detailindex.
See also #80. Hopefully others can offer more advice...

@gummif
Copy link
Member

gummif commented Jan 9, 2023

You should be able to use e.g. the detailrange function to get the range at some level and the scaling range at that level you can compute from the detail range (1 to first of detail - 1). Then it is a matter of computing all possible combination of indexes for all levels.

If you can come up with a good solution to iterate the coefficients in higher dimensions rhat would be a great addition to this package.

@ktaswell
Copy link
Author

Hi, Thank you both for your comments, I really appreciate the help.

@JeffFessler, I am just starting my journey into medical image processing so thank you for these links! The breakdown of wavelet levels supported what I was thinking, though I'll need to look more carefully at your code to verify.

@gummif I've been thinking about a few different improvements to Wavelets.jl including this suggestion. Hopefully I will get a chance to work on this soon. If I'm am free to, I'll update this thread with a link to my code.

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

No branches or pull requests

3 participants