Search in sources :

Example 1 with BorderIndex1D_Wrap

use of boofcv.core.image.border.BorderIndex1D_Wrap in project BoofCV by lessthanoptimal.

the class PermuteWaveletCompare method createDesc_I32.

private WaveletDescription<WlCoef_I32> createDesc_I32(int offset, int length, BorderType type) {
    WlCoef_I32 forward = createRandomCoef_I32(offset, length);
    BorderIndex1D border;
    WlBorderCoef<WlCoef_I32> inverse;
    if (type == BorderType.WRAP) {
        inverse = new WlBorderCoefStandard<>(forward);
        border = new BorderIndex1D_Wrap();
    } else {
        inverse = createFixedCoef_I32(forward);
        border = new BorderIndex1D_Reflect();
    }
    return new WaveletDescription<>(border, forward, inverse);
}
Also used : BorderIndex1D_Wrap(boofcv.core.image.border.BorderIndex1D_Wrap) BorderIndex1D(boofcv.core.image.border.BorderIndex1D) BorderIndex1D_Reflect(boofcv.core.image.border.BorderIndex1D_Reflect)

Example 2 with BorderIndex1D_Wrap

use of boofcv.core.image.border.BorderIndex1D_Wrap in project BoofCV by lessthanoptimal.

the class FactoryWaveletCoiflet method generate_F32.

/**
 * Creates a description of a Coiflet of order I wavelet.
 * @param I order of the wavelet.
 * @return Wavelet description.
 */
public static WaveletDescription<WlCoef_F32> generate_F32(int I) {
    if (I != 6) {
        throw new IllegalArgumentException("Only 6 is currently supported");
    }
    WlCoef_F32 coef = new WlCoef_F32();
    coef.offsetScaling = -2;
    coef.offsetWavelet = -2;
    coef.scaling = new float[6];
    coef.wavelet = new float[6];
    double sqrt7 = Math.sqrt(7);
    double div = 16.0 * Math.sqrt(2);
    coef.scaling[0] = (float) ((1.0 - sqrt7) / div);
    coef.scaling[1] = (float) ((5.0 + sqrt7) / div);
    coef.scaling[2] = (float) ((14.0 + 2.0 * sqrt7) / div);
    coef.scaling[3] = (float) ((14.0 - 2.0 * sqrt7) / div);
    coef.scaling[4] = (float) ((1.0 - sqrt7) / div);
    coef.scaling[5] = (float) ((-3.0 + sqrt7) / div);
    coef.wavelet[0] = coef.scaling[5];
    coef.wavelet[1] = -coef.scaling[4];
    coef.wavelet[2] = coef.scaling[3];
    coef.wavelet[3] = -coef.scaling[2];
    coef.wavelet[4] = coef.scaling[1];
    coef.wavelet[5] = -coef.scaling[0];
    WlBorderCoefStandard<WlCoef_F32> inverse = new WlBorderCoefStandard<>(coef);
    return new WaveletDescription<>(new BorderIndex1D_Wrap(), coef, inverse);
}
Also used : BorderIndex1D_Wrap(boofcv.core.image.border.BorderIndex1D_Wrap) WlCoef_F32(boofcv.struct.wavelet.WlCoef_F32) WaveletDescription(boofcv.struct.wavelet.WaveletDescription) WlBorderCoefStandard(boofcv.struct.wavelet.WlBorderCoefStandard)

Example 3 with BorderIndex1D_Wrap

use of boofcv.core.image.border.BorderIndex1D_Wrap in project BoofCV by lessthanoptimal.

the class FactoryWaveletDaub method daubJ_F32.

/**
 * <p>
 * DaubJ wavelets have the following properties:<br>
 * <ul>
 * <li>Conserve the signal's energy</li>
 * <li>If the signal is approximately polynomial of degree J/2-1 or less within the support then fluctuations are approximately zero.</li>
 * <li>The sum of the scaling numbers is sqrt(2)</li>
 * <li>The sum of the wavelet numbers is 0</li>
 * </ul>
 * </p>
 *
 * @param J The wavelet's degree.
 * @return Description of the DaubJ wavelet.
 */
public static WaveletDescription<WlCoef_F32> daubJ_F32(int J) {
    if (J != 4) {
        throw new IllegalArgumentException("Only 4 is currently supported");
    }
    WlCoef_F32 coef = new WlCoef_F32();
    coef.offsetScaling = 0;
    coef.offsetWavelet = 0;
    coef.scaling = new float[4];
    coef.wavelet = new float[4];
    double sqrt3 = Math.sqrt(3);
    double div = 4.0 * Math.sqrt(2);
    coef.scaling[0] = (float) ((1 + sqrt3) / div);
    coef.scaling[1] = (float) ((3 + sqrt3) / div);
    coef.scaling[2] = (float) ((3 - sqrt3) / div);
    coef.scaling[3] = (float) ((1 - sqrt3) / div);
    coef.wavelet[0] = coef.scaling[3];
    coef.wavelet[1] = -coef.scaling[2];
    coef.wavelet[2] = coef.scaling[1];
    coef.wavelet[3] = -coef.scaling[0];
    WlBorderCoefStandard<WlCoef_F32> inverse = new WlBorderCoefStandard<>(coef);
    return new WaveletDescription<>(new BorderIndex1D_Wrap(), coef, inverse);
}
Also used : BorderIndex1D_Wrap(boofcv.core.image.border.BorderIndex1D_Wrap)

Example 4 with BorderIndex1D_Wrap

use of boofcv.core.image.border.BorderIndex1D_Wrap in project BoofCV by lessthanoptimal.

the class FactoryWaveletDaub method biorthogonal_F32.

/**
 * <p>
 * Daub J/K biorthogonal wavelets have the following properties:<br>
 * <ul>
 * <li>DO NOT conserve the signal's energy</li>
 * <li>If the signal is approximately polynomial of degree (J-1)/2-1 within the support then fluctuations are approximately zero.</li>
 * <li>The sum of the scaling numbers is 1</li>
 * <li>The sum of the wavelet numbers is 0</li>
 * </ul>
 * </p>
 *
 * @param J The wavelet's degree. K = J-2.
 * @param borderType How image borders are handled.
 * @return Description of the Daub J/K wavelet.
 */
public static WaveletDescription<WlCoef_F32> biorthogonal_F32(int J, BorderType borderType) {
    if (J != 5) {
        throw new IllegalArgumentException("Only 5 is currently supported");
    }
    WlCoef_F32 forward = new WlCoef_F32();
    forward.offsetScaling = -2;
    forward.offsetWavelet = 0;
    forward.scaling = new float[5];
    forward.wavelet = new float[3];
    forward.scaling[0] = (float) (-1.0 / 8.0);
    forward.scaling[1] = (float) (2.0 / 8.0);
    forward.scaling[2] = (float) (6.0 / 8.0);
    forward.scaling[3] = (float) (2.0 / 8.0);
    forward.scaling[4] = (float) (-1.0 / 8.0);
    forward.wavelet[0] = -1.0f / 2.0f;
    forward.wavelet[1] = 1;
    forward.wavelet[2] = -1.0f / 2.0f;
    BorderIndex1D border;
    WlBorderCoef<WlCoef_F32> inverse;
    if (borderType == BorderType.REFLECT) {
        WlCoef_F32 inner = computeInnerInverseBiorthogonal(forward);
        border = new BorderIndex1D_Reflect();
        inverse = computeBorderCoefficients(border, forward, inner);
    } else if (borderType == BorderType.WRAP) {
        WlCoef_F32 inner = computeInnerInverseBiorthogonal(forward);
        inverse = new WlBorderCoefStandard<>(inner);
        border = new BorderIndex1D_Wrap();
    } else {
        throw new IllegalArgumentException("Unsupported border type: " + borderType);
    }
    return new WaveletDescription<>(border, forward, inverse);
}
Also used : BorderIndex1D_Wrap(boofcv.core.image.border.BorderIndex1D_Wrap) BorderIndex1D(boofcv.core.image.border.BorderIndex1D) BorderIndex1D_Reflect(boofcv.core.image.border.BorderIndex1D_Reflect)

Example 5 with BorderIndex1D_Wrap

use of boofcv.core.image.border.BorderIndex1D_Wrap in project BoofCV by lessthanoptimal.

the class FactoryWaveletDaub method biorthogonal_I32.

/**
 * Integer version of {@link #biorthogonal_F32}.
 *
 * @param J The wavelet's degree. K = J-2.
 * @param borderType How image borders are handled.
 * @return Description of the Daub J/K wavelet.
 */
public static WaveletDescription<WlCoef_I32> biorthogonal_I32(int J, BorderType borderType) {
    if (J != 5) {
        throw new IllegalArgumentException("Only 5 is currently supported");
    }
    WlCoef_I32 forward = new WlCoef_I32();
    forward.offsetScaling = -2;
    forward.offsetWavelet = 0;
    forward.scaling = new int[5];
    forward.wavelet = new int[3];
    forward.denominatorScaling = 8;
    forward.scaling[0] = -1;
    forward.scaling[1] = 2;
    forward.scaling[2] = 6;
    forward.scaling[3] = 2;
    forward.scaling[4] = -1;
    forward.denominatorWavelet = 2;
    forward.wavelet[0] = -1;
    forward.wavelet[1] = 2;
    forward.wavelet[2] = -1;
    BorderIndex1D border;
    WlBorderCoef<WlCoef_I32> inverse;
    if (borderType == BorderType.WRAP) {
        WlCoef_I32 inner = computeInnerBiorthogonalInverse(forward);
        inverse = new WlBorderCoefStandard<>(inner);
        border = new BorderIndex1D_Wrap();
    } else if (borderType == BorderType.REFLECT) {
        WlCoef_I32 inner = computeInnerBiorthogonalInverse(forward);
        inverse = convertToInt((WlBorderCoefFixed<WlCoef_F32>) biorthogonal_F32(J, borderType).getInverse(), inner);
        border = new BorderIndex1D_Reflect();
    } else {
        throw new IllegalArgumentException("Unsupported border type: " + borderType);
    }
    return new WaveletDescription<>(border, forward, inverse);
}
Also used : BorderIndex1D_Wrap(boofcv.core.image.border.BorderIndex1D_Wrap) BorderIndex1D(boofcv.core.image.border.BorderIndex1D) BorderIndex1D_Reflect(boofcv.core.image.border.BorderIndex1D_Reflect)

Aggregations

BorderIndex1D_Wrap (boofcv.core.image.border.BorderIndex1D_Wrap)6 BorderIndex1D (boofcv.core.image.border.BorderIndex1D)4 BorderIndex1D_Reflect (boofcv.core.image.border.BorderIndex1D_Reflect)4 WaveletDescription (boofcv.struct.wavelet.WaveletDescription)1 WlBorderCoefStandard (boofcv.struct.wavelet.WlBorderCoefStandard)1 WlCoef_F32 (boofcv.struct.wavelet.WlCoef_F32)1