I wanted to experiment with directional multiscale transforms, so I created my own implementations. I haven’t released them yet (except for Contourlets.jl) because I wanted to ask for some opinions on AbstractMultiscaleTransforms. The goal of this package is to have a unified interface for all multiscale transforms, potentially beyond the three mentioned ones (e.g. Wavelets.jl).
The Proposed Interface
x = randn(256, 256)
t = BandlimitedShearlets(scales = 3) # transform: parameters only
c = analyze(t, x) # coefficients: an AbstractArray
b = subband(t, c, 2) # view of subband 2 (subband 1 is the lowpass)
synthesize(t, c) ≈ x # true
ws = make_workspace(t, x) # precomputed plans/buffers for this size and eltype
analyze!(c, ws, x) # repeated calls allocate little or nothing
Defined Types
-
Transform (
<: AbstractMultiscaleTransform): an immutable value that holds every parameter (scales, directions, filters) and nothing that depends on the data’s size or element type. One transform therefore works for any admissible size. Transforms with equal parameters return “true” for==. -
Workspace (
<: AbstractTransformWorkspace, produced bymake_workspace(t, x)ormake_workspace(t, T, dims)): holds FFT plans, filter responses and scratch buffers for one size, element type and array type (CPU or GPU).- Every function, where applicable, accepts the “workspace” keyword, and a workspace can also stand in for its transform (e.g.
analyze(ws, x)). A transform that precomputes nothing still returns a DefaultWorkspace, so generic code never has to branch.
- Every function, where applicable, accepts the “workspace” keyword, and a workspace can also stand in for its transform (e.g.
-
Coefficients: always an AbstractArray, so generic code can broadcast over them and call
norm,dot,axpy!and so on. They come in three layouts:- packed into an array of the same size as
xfor critically sampled separable transforms, like currently 2D and 3Ddwtoutputs in Wavelets.jl, - stacked, when all subbands have the same size as the input (nonsubsampled transforms): an array of size
(size(x)..., n); - SubbandVector, when subband sizes differ (decimated transforms): all subbands flattened, packed one after another into a single vector, with some helpers to get correctly sized views. Element-wise arithmetic can operate directly on the storage vector.
- packed into an array of the same size as
The functions
analyze(t, x), analyze!(c, t, x): forward transformsynthesize(t, c), synthesize!(x, t, c): inverse transformmake_workspace: create a workspacetransform(ws): “extracts” the transform object from a workspacesimilar_coefficients(t, x): allocates uninitialized storage for the output ofanalyze!subband,nsubbands,subband_layout: helpers for subband accessanalyze(f, t, x),synthesize!(f, x, t): optional streaming: f(i, band) is called per subband instead of storing all coefficients
Conventions
- synthesize inverts analyze. It is the adjoint only for Parseval frames, and each package documents which of its transforms are Parseval frames.
- Complex data is transformed as its real and imaginary parts, so analyze(t, x + im * y) ≈ analyze(t, x) + im * analyze(t, y).
analyze,synthesize(and their in-place variants) acceptthreaded = nothing | true | false.- Invalid input throws
DimensionMismatchorArgumentErrorbefore any work is done.
The proposed API can be studied in more detail on GitHub: GitHub - hakkelt/AbstractMultiscaleTransforms.jl: Abstract interface for multiscale transforms in Julia · GitHub
My Questions
- What other transforms might fit under this API? What would be a suitable scope?
- Is this a good name (that’s a thing I cannot change after registration, so that question always makes me nervous about whether I’ll regret the choice later…)?
- Are there any suggestions to improve the proposed API or to broaden its scope? I’m still not fully convinced whether “analyze/synthesize” and “workspace” are the best choices. Also I considered
ArrayPartitionfrom RecursiveArrayTools.jl, but it might not be worth adding a heavy dependency.
Notes
- I just realized, while writing this post, that there was a previous package for Shearlets (Shearlab.jl), but it’s an unmaintained old package for Julia before 1.0.
- To be honest, I have only a user-level understanding of the theory behind these transforms, so I needed to trust my AI agent to implement it faithfully. So help would be really welcome to verify correctness. What I could do was:
- ensure the code quality,
- do some comparisons of the output of my packages against the output of the original MATLAB toolboxes (but didn’t allow agents to read their source, because most are GPL-licensed or have no license), and
- check whether the generated images look similar to those in the papers…

- Here are my packages that implement the proposed interface:
- GitHub - hakkelt/Contourlets.jl: Discrete and nonsubsampled contourlet transform in Julia with GPU support · GitHub
- GitHub - hakkelt/Surfacelets.jl: The surfacelet transform in Julia: multiscale, multidirectional transform for volumes, with GPU support · GitHub
- GitHub - hakkelt/Shearlets.jl: Translation-invariant discrete shearlet transforms of images and volumes in Julia, with GPU support · GitHub