use of boofcv.struct.image.GrayS32 in project BoofCV by lessthanoptimal.
the class GeneralImageSuperpixelsChecks method subimage.
/**
* Make sure subimages produce the same results
*/
@Test
public void subimage() {
for (ImageType<T> t : imageTypes) {
// System.out.println("Image type "+t);
ImageSuperpixels<T> alg = createAlg(t);
T input = t.createImage(width, height);
GrayS32 expected = new GrayS32(width, height);
GImageMiscOps.fillUniform(input, rand, 0, 100);
alg.segment(input, expected);
// provide an output which is a sub-image
GrayS32 found = new GrayS32(width + 3, height + 2).subimage(2, 1, width + 2, height + 1);
alg.segment(input, found);
BoofTesting.assertEquals(expected, found, 0);
// Now make the input image an output
input = BoofTesting.createSubImageOf(input);
found = new GrayS32(width, height);
alg.segment(input, found);
BoofTesting.assertEquals(expected, found, 0);
}
}
use of boofcv.struct.image.GrayS32 in project BoofCV by lessthanoptimal.
the class WaveletTransformOps method inverseN.
/**
* <p>Performs a level N inverse fast wavelet transform (FWT).</p>
*
* <p>To save memory the input image is used to store intermediate results and is modified.</p>
*
* @param desc Description of the inverse wavelet.
* @param input Input wavelet transform and is used as internal workspace. Modified.
* @param output Reconstruction of original image. Modified.
* @param storage Optional storage image. Should be the same size as the input image. If null then
* an image is declared internally.
* @param numLevels Number of levels in the transform.
* @param minValue Minimum allowed pixel value
* @param maxValue Maximum allowed pixel value
*/
public static void inverseN(WaveletDescription<WlCoef_I32> desc, GrayS32 input, GrayS32 output, GrayS32 storage, int numLevels, int minValue, int maxValue) {
if (numLevels == 1) {
inverse1(desc, input, output, storage, minValue, maxValue);
PixelMath.boundImage(output, minValue, maxValue);
return;
}
UtilWavelet.checkShape(desc.getForward(), output, input, numLevels);
storage = InputSanityCheck.checkDeclare(input, storage);
// modify the shape of a temporary image not the original
storage = storage.subimage(0, 0, input.width, input.height, null);
storage.subImage = false;
int width, height;
int scale = UtilWavelet.computeScale(numLevels);
width = input.width / scale;
height = input.height / scale;
width += width % 2;
height += height % 2;
GrayS32 levelIn = input.subimage(0, 0, width, height, null);
GrayS32 levelOut = output.subimage(0, 0, width, height, null);
storage.reshape(width, height);
inverse1(desc, levelIn, levelOut, storage, Integer.MIN_VALUE, Integer.MAX_VALUE);
for (int i = numLevels - 1; i >= 1; i--) {
// copy the decoded segment into the input
levelIn.setTo(levelOut);
if (i > 1) {
scale /= 2;
width = input.width / scale;
height = input.height / scale;
width += width % 2;
height += height % 2;
storage.reshape(width, height);
levelIn = input.subimage(0, 0, width, height, null);
levelOut = output.subimage(0, 0, width, height, null);
} else {
levelIn = input;
levelOut = output;
}
storage.reshape(levelIn.width, levelIn.height);
inverse1(desc, levelIn, levelOut, storage, Integer.MIN_VALUE, Integer.MAX_VALUE);
}
if (minValue != Integer.MIN_VALUE && maxValue != Integer.MAX_VALUE)
PixelMath.boundImage(output, minValue, maxValue);
}
use of boofcv.struct.image.GrayS32 in project BoofCV by lessthanoptimal.
the class GenericBinaryContourFinder method saveInternal.
@Test
public void saveInternal() {
GrayU8 input = TEST3.clone();
GrayS32 labeled = input.createSameShape(GrayS32.class);
BinaryContourFinder alg = create();
alg.process(input, labeled);
checkInternalSize(alg, 0, 0, 8);
alg.setSaveInnerContour(false);
alg.process(input, labeled);
checkInternalSize(alg, 0, 0, 0);
}
use of boofcv.struct.image.GrayS32 in project BoofCV by lessthanoptimal.
the class GenericBinaryContourFinder method minContour.
@Test
public void minContour() {
GrayU8 input = TEST3.clone();
GrayS32 labeled = input.createSameShape(GrayS32.class);
BinaryContourFinder alg = create();
alg.setMinContour(1000);
alg.process(input, labeled);
assertEquals(1, alg.getContours().size());
checkExternalSize(alg, 0, 0);
}
use of boofcv.struct.image.GrayS32 in project BoofCV by lessthanoptimal.
the class GenericBinaryContourFinder method connectRule.
@Test
public void connectRule() {
GrayU8 input = TEST3.clone();
GrayS32 labeled = input.createSameShape(GrayS32.class);
BinaryContourFinder alg = create();
alg.process(input, labeled);
checkExternalSize(alg, 0, 10);
alg.setConnectRule(ConnectRule.EIGHT);
alg.process(input, labeled);
checkExternalSize(alg, 0, 8);
}
Aggregations