Search in sources :

Example 6 with ImageDimension

use of boofcv.struct.image.ImageDimension in project BoofCV by lessthanoptimal.

the class TestWaveletTransformOps method checkOverflowN.

public <T extends ImageGray<T>> void checkOverflowN(Class<T> typeInput) {
    this.typeInput = typeInput;
    WaveletDescription<?> desc = createDesc(typeInput);
    int width = 20;
    int height = 22;
    int level = 3;
    ImageDimension dim = UtilWavelet.transformDimension(width, height, level);
    T transform = GeneralizedImageOps.createSingleBand(typeInput, dim.width, dim.height);
    T found = GeneralizedImageOps.createSingleBand(typeInput, width, height);
    GImageMiscOps.fillUniform(transform, rand, 100, 150);
    invokeTransformN(desc, null, transform, found, 3, 100, 150);
    checkBounds(found, 100, 150);
}
Also used : ImageDimension(boofcv.struct.image.ImageDimension)

Example 7 with ImageDimension

use of boofcv.struct.image.ImageDimension in project BoofCV by lessthanoptimal.

the class TestWaveletTransformOps method testMultipleLevels.

private void testMultipleLevels(Class typeInput) {
    this.typeInput = typeInput;
    WaveletDescription<?> desc = createDesc(typeInput);
    // try different sized images
    for (int adjust = 0; adjust < 5; adjust++) {
        int w = width + adjust;
        int h = height + adjust;
        ImageGray input = GeneralizedImageOps.createSingleBand(typeInput, w, h);
        ImageGray found = GeneralizedImageOps.createSingleBand(typeInput, w, h);
        GImageMiscOps.fillUniform(input, rand, 0, 50);
        for (int level = 1; level <= 5; level++) {
            ImageDimension dim = UtilWavelet.transformDimension(w, h, level);
            ImageGray output = GeneralizedImageOps.createSingleBand(typeInput, dim.width, dim.height);
            // System.out.println("adjust "+adjust+" level "+level+" scale "+ div);
            invokeTransformN(desc, (ImageGray) input.clone(), output, found, level, 0, 255);
            BoofTesting.assertEquals(input, found, 1e-4f);
        }
    }
}
Also used : ImageDimension(boofcv.struct.image.ImageDimension) ImageGray(boofcv.struct.image.ImageGray)

Example 8 with ImageDimension

use of boofcv.struct.image.ImageDimension in project BoofCV by lessthanoptimal.

the class TestWaveletTransformFloat32 method compareToWaveletTransformOps.

@Test
public void compareToWaveletTransformOps() {
    GrayF32 orig = new GrayF32(width, height);
    GImageMiscOps.fillUniform(orig, rand, 0, 20);
    GrayF32 origCopy = orig.clone();
    int N = 3;
    ImageDimension dimen = UtilWavelet.transformDimension(orig, N);
    GrayF32 found = new GrayF32(dimen.width, dimen.height);
    GrayF32 expected = new GrayF32(dimen.width, dimen.height);
    WaveletDescription<WlCoef_F32> desc = FactoryWaveletDaub.biorthogonal_F32(5, BorderType.REFLECT);
    GrayF32 storage = new GrayF32(dimen.width, dimen.height);
    WaveletTransformOps.transformN(desc, orig.clone(), expected, storage, N);
    WaveletTransformFloat32 alg = new WaveletTransformFloat32(desc, N, 0, 255);
    alg.transform(orig, found);
    // make sure the original input was not modified like it is in WaveletTransformOps
    BoofTesting.assertEquals(origCopy, orig, 1e-4);
    // see if the two techniques produced the same results
    BoofTesting.assertEquals(expected, found, 1e-4);
    // test inverse transform
    GrayF32 reconstructed = new GrayF32(width, height);
    alg.invert(found, reconstructed);
    BoofTesting.assertEquals(orig, reconstructed, 1e-4);
    // make sure the input has not been modified
    BoofTesting.assertEquals(expected, found, 1e-4);
}
Also used : WlCoef_F32(boofcv.struct.wavelet.WlCoef_F32) GrayF32(boofcv.struct.image.GrayF32) ImageDimension(boofcv.struct.image.ImageDimension) Test(org.junit.Test)

Example 9 with ImageDimension

use of boofcv.struct.image.ImageDimension in project BoofCV by lessthanoptimal.

the class TestWaveletTransformInt method checkOtherType.

/**
 * See how well it processes an image which is not an GrayS32
 */
@Test
public void checkOtherType() {
    GrayS32 orig = new GrayS32(width, height);
    GImageMiscOps.fillUniform(orig, rand, 0, 20);
    GrayU8 orig8 = ConvertImage.convert(orig, (GrayU8) null);
    int N = 3;
    ImageDimension dimen = UtilWavelet.transformDimension(orig, N);
    GrayS32 found = new GrayS32(dimen.width, dimen.height);
    GrayS32 expected = new GrayS32(dimen.width, dimen.height);
    WaveletDescription<WlCoef_I32> desc = FactoryWaveletDaub.biorthogonal_I32(5, BorderType.REFLECT);
    GrayS32 storage = new GrayS32(dimen.width, dimen.height);
    WaveletTransformOps.transformN(desc, orig.clone(), expected, storage, N);
    WaveletTransformInt<GrayU8> alg = new WaveletTransformInt<>(desc, N, 0, 255, GrayU8.class);
    alg.transform(orig8, found);
    // see if the two techniques produced the same results
    BoofTesting.assertEquals(expected, found, 0);
    // see if it can convert it back
    GrayU8 reconstructed = new GrayU8(width, height);
    alg.invert(found, reconstructed);
    BoofTesting.assertEquals(orig8, reconstructed, 0);
    // make sure the input has not been modified
    BoofTesting.assertEquals(expected, found, 0);
}
Also used : WlCoef_I32(boofcv.struct.wavelet.WlCoef_I32) ImageDimension(boofcv.struct.image.ImageDimension) GrayU8(boofcv.struct.image.GrayU8) GrayS32(boofcv.struct.image.GrayS32) Test(org.junit.Test)

Aggregations

ImageDimension (boofcv.struct.image.ImageDimension)9 GrayS32 (boofcv.struct.image.GrayS32)3 Test (org.junit.Test)3 GrayF32 (boofcv.struct.image.GrayF32)2 WlCoef_I32 (boofcv.struct.wavelet.WlCoef_I32)2 GrayU8 (boofcv.struct.image.GrayU8)1 ImageGray (boofcv.struct.image.ImageGray)1 WlCoef_F32 (boofcv.struct.wavelet.WlCoef_F32)1