Wavelet filter artifact

I would like to denoise some data using wavelet filters. My current approach is to employ the stationary wavelet transform with Haar wavelets.

However, this leads to undesirable artifacts at the top and bottom boundary of the dataset, as you can see in the figure. Is there a clever way to suppress these artifacts?

I am especially interested in removing the initial drop of the raised profile after the wavelet filter. The code to generate the figure is:

sigma[y_] := 0.03 + y;
box[x_] := Piecewise[{{1.0, -0.5 <= x <= 0.5}, {0, True}}]
crossx[w_] := box[w];
dataMax = MovingAverage[#, 10] & /@ MovingAverage[#, 5] &@ Table[crossx[x/sigma[y]], {x, -1, 1, 0.01}, {y, 0, 1.0, 0.01}];
dataMin = Map[Max[# - 0.4, 0.] &, dataMax, {2}];
{ni, nj} = Dimensions[dataMin];
data = Table[RandomReal[{dataMin[[i, j]], dataMax[[i, j]]}], {i, 1, ni}, {j, 1, nj}];

img = Image[Transpose[data]];
wvt = StationaryWaveletTransform[img, HaarWavelet[], 4];
wvfilter = WaveletMapIndexed[ImageMultiply[#, 0] &, wvt, {___, 1 | 2 | 3}];
iwvt = InverseWaveletTransform[wvfilter];

ops = {PlotRange -> {0, 1}, ViewPoint -> {-2.53, -1.27, 1.86}, ImageSize -> 400, ColorFunction -> "TemperatureMap"};
p1 = ListPlot3D[dataMin, Evaluate[ops], PlotLabel -> "clean dataset"];
p2 = ListPlot3D[data, Evaluate[ops], PlotLabel -> "noisy dataset"];
p3 = ListPlot3D[Transpose[ImageData[iwvt][[1 ;; -1]]], Evaluate[ops],PlotLabel -> "dataset after wavelet"];
p = Grid[{{p1, p2, p3}}]
Export[FileNameJoin[{\$HomeDirectory, "Desktop",
"wavelet_filter_test.png"}], p];
• If you want to denoise data with a sharp transition, you could consider median filtering. Jun 27 '17 at 4:31

The observed boundary artifacts can be reduced in part by applying a wavelet threshold to smooth the data noise. Also, the filtered wavelet can be composed as a mixture of fluctuations components in a multilevel scheme. Each wavelet index component can be added in proportion defined by the multiplication factor in the command ImageMultiply[#,factor].

wvt = StationaryWaveletTransform[img, HaarWavelet[], 4];
wvt = WaveletThreshold[wvt, {"SmoothGarrote", 0.05, 1}];

wvfilter =
WaveletMapIndexed[ImageMultiply[#, 1.0] &,
WaveletMapIndexed[ImageMultiply[#, 0.05] &,
WaveletMapIndexed[ImageMultiply[#, 0.01] &, wvt,
{1 | 2 | 3}], {0, 1 | 2 | 3}], {0, 0, 1 | 2 | 3}];

iwvt = InverseWaveletTransform[wvfilter];  However, the remaining edge distortions cannot be reduced with this technique. Unfortunately, the command StationaryWaveletTransform does not have an option Padding to lower the boundary effects.