@Test public void compareToWaveletTransformOps() { GrayS32 orig = new GrayS32(width, height); GImageMiscOps.fillUniform(orig, rand, 0, 20); GrayS32 origCopy = orig.clone(); 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<GrayS32> alg = new WaveletTransformInt<>(desc, N, 0, 255, GrayS32.class); alg.transform(orig, found); // make sure the original input was not modified like it is in WaveletTransformOps BoofTesting.assertEquals(origCopy, orig, 0); // see if the two techniques produced the same results BoofTesting.assertEquals(expected, found, 0); // test inverse transform GrayS32 reconstructed = new GrayS32(width, height); alg.invert(found, reconstructed); BoofTesting.assertEquals(orig, reconstructed, 0); // make sure the input has not been modified BoofTesting.assertEquals(expected, found, 0); }
/** 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); }