arsenal9971 / Shearlab.jl

Shearlab is a Julia Library with toolbox for two- and threedimensional data processing using the Shearlet system as basis functions which generates an sparse representation of cartoon-like functions.
https://arsenal9971.github.io/Shearlab.jl/
Other
31 stars 9 forks source link

Edge effects for non-periodic data #19

Open dsweber2 opened 6 years ago

dsweber2 commented 6 years ago

Turns out when I use the shearlet transform on functions which are non-periodic, I get edges showing up where they shouldn't be. This also happens in the Matlab version; I haven't had time to check either pyshearlab, bendlab, or PPFT. A pretty clear example:

using Shearlab, Plots
pyplot()
X = zeros(500,500)
X[200:300,250:500] = 1
heatmap(X)
system = Shearlab.SLgetShearletSystem2D(size(X)...,3)
sheared = Shearlab.SLsheardec2D(X,system)
heatmap(abs(sheared[:,:,2]))

data: edgeeffectsdata Second Shearlet: edgeeffects The problem is on the outsides of the transformed result: there's no edge there to detect (especially on the left), but because the fft interprets the signal as periodic, we get a jump from one side to the other.

There are certainly ways to address the issue. User-side, one could just mirror the data over both axes; however, this has run into memory problems for me. Since the Shearlet transform is implemented using a fft, I suspect that there's a way to adjust the creation of the coefficients to use the dct, which is equivalent to the mirroring, without the increase in memory usage.