use of boofcv.struct.image.ImageDimension in project BoofCV by lessthanoptimal.
the class WaveletTransformFloat32 method transform.
@Override
public GrayF32 transform(GrayF32 original, GrayF32 transformed) {
if (transformed == null) {
ImageDimension d = UtilWavelet.transformDimension(original, numLevels);
transformed = new GrayF32(d.width, d.height);
}
temp.reshape(transformed.width, transformed.height);
copy.reshape(original.width, original.height);
copy.setTo(original);
WaveletTransformOps.transformN(desc, copy, transformed, temp, numLevels);
return transformed;
}
use of boofcv.struct.image.ImageDimension in project BoofCV by lessthanoptimal.
the class WaveletTransformInt method transform.
@Override
public GrayS32 transform(T original, GrayS32 transformed) {
if (transformed == null) {
ImageDimension d = UtilWavelet.transformDimension(original, numLevels);
transformed = new GrayS32(d.width, d.height);
}
temp.reshape(transformed.width, transformed.height);
copyInput.reshape(original.width, original.height);
if (original.getDataType().getDataType() == int.class) {
copyInput.setTo((GrayS32) original);
} else {
GConvertImage.convert(original, copyInput);
}
WaveletTransformOps.transformN(desc, copyInput, transformed, temp, numLevels);
return transformed;
}
use of boofcv.struct.image.ImageDimension in project BoofCV by lessthanoptimal.
the class TestWaveletTransformInt method compareToWaveletTransformOps.
@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);
}
use of boofcv.struct.image.ImageDimension in project BoofCV by lessthanoptimal.
the class WaveletDenoiseFilter method process.
@Override
public void process(T original, T denoised) {
// compute the wavelet transform
if (transform != null) {
ImageDimension d = UtilWavelet.transformDimension(original, wavelet.getLevels());
transform.reshape(d.width, d.height);
}
transform = wavelet.transform(original, transform);
// remove noise from the transformed image
alg.denoise(transform, wavelet.getLevels());
// reverse the transform
wavelet.invert(transform, denoised);
}
use of boofcv.struct.image.ImageDimension in project BoofCV by lessthanoptimal.
the class TestUtilWavelet method adjustForDisplay.
public <T extends ImageGray<T>> void adjustForDisplay(Class<T> imageType) {
ImageDimension d = UtilWavelet.transformDimension(320, 240, 3);
T b = GeneralizedImageOps.createSingleBand(imageType, d.width, d.height);
GImageMiscOps.fillUniform(b, rand, 0, 200);
UtilWavelet.adjustForDisplay(b, 3, 255);
}
Aggregations