use of boofcv.struct.image.GrayS32 in project BoofCV by lessthanoptimal.
the class Watershed_to_ImageSuperpixels method segment.
@Override
public void segment(T input, GrayS32 output) {
InputSanityCheck.checkSameShape(input, output);
converted.reshape(input.width, input.height);
GConvertImage.convert(input, converted);
// segment the image
alg.process(converted);
alg.removeWatersheds();
numRegions = alg.getTotalRegions();
GrayS32 pixelToRegion = alg.getOutput();
// Merge small regions together
if (pruneSmall != null) {
regionMemberCount.resize(numRegions);
regionColor.resize(numRegions);
ImageSegmentationOps.countRegionPixels(pixelToRegion, numRegions, regionMemberCount.data);
pruneSmall.process(converted, pixelToRegion, regionMemberCount, regionColor);
numRegions = regionMemberCount.size();
}
output.setTo(pixelToRegion);
}
use of boofcv.struct.image.GrayS32 in project BoofCV by lessthanoptimal.
the class KernelMath method convertToImage.
public static GrayS32 convertToImage(Kernel2D_S32 kernel) {
int w = kernel.getWidth();
GrayS32 ret = new GrayS32(w, w);
for (int i = 0; i < w; i++) {
for (int j = 0; j < w; j++) {
ret.set(j, i, kernel.get(j, i));
}
}
return ret;
}
use of boofcv.struct.image.GrayS32 in project BoofCV by lessthanoptimal.
the class DerivativeHelperFunctions method processBorderVertical.
public static void processBorderVertical(GrayU8 orig, GrayS32 deriv, Kernel1D_S32 kernel, ImageBorder_S32 borderType) {
borderType.setImage(orig);
ConvolveJustBorder_General_SB.vertical(kernel, borderType, deriv);
GrayU8 origSub;
GrayS32 derivSub;
origSub = orig.subimage(0, 0, 2, orig.height, null);
derivSub = deriv.subimage(0, 0, 2, orig.height, null);
ConvolveImageNoBorder.vertical(kernel, origSub, derivSub);
origSub = orig.subimage(orig.width - 2, 0, orig.width, orig.height, null);
derivSub = deriv.subimage(orig.width - 2, 0, orig.width, orig.height, null);
ConvolveImageNoBorder.vertical(kernel, origSub, derivSub);
}
use of boofcv.struct.image.GrayS32 in project BoofCV by lessthanoptimal.
the class CommonFactoryWavelet method checkEncodeDecode_I32.
/**
* See if the provided wavelets can be used to transform the image and change it back without error
*
* @param waveletDesc The wavelet being tested
*/
public void checkEncodeDecode_I32(WaveletDescription<WlCoef_I32> waveletDesc) {
// test both even and odd images
for (int makeOdd = 0; makeOdd <= 1; makeOdd++) {
GrayS32 orig = new GrayS32(width - makeOdd, height - makeOdd);
GrayS32 tran = new GrayS32(width, height);
GrayS32 rev = new GrayS32(width - makeOdd, height - makeOdd);
ImageMiscOps.fillUniform(orig, rand, -50, 50);
BorderIndex1D border = waveletDesc.getBorder();
ImplWaveletTransformNaive.horizontal(border, waveletDesc.forward, orig, tran);
ImplWaveletTransformNaive.horizontalInverse(border, waveletDesc.inverse, tran, rev);
BoofTesting.assertEquals(orig, rev, 0);
// quick sanity check to make sure that WaveletTransformOps
// also correctly does a transform with these wavelets
// more of a robustness test of WaveletTransformOps than anything else
WaveletTransformOps.transform1(waveletDesc, orig, tran, null);
WaveletTransformOps.inverse1(waveletDesc, tran, rev, null, Integer.MIN_VALUE, Integer.MAX_VALUE);
BoofTesting.assertEquals(orig, rev, 0);
}
}
use of boofcv.struct.image.GrayS32 in project BoofCV by lessthanoptimal.
the class TestImplIntegralImageOps method block_zero.
public void block_zero(Method m) throws InvocationTargetException, IllegalAccessException {
Class[] paramType = m.getParameterTypes();
Class inputType = paramType[0];
Class origType = inputType == GrayS32.class ? GrayU8.class : inputType;
ImageGray input = GeneralizedImageOps.createSingleBand(origType, width, height);
ImageGray integral = GeneralizedImageOps.createSingleBand(inputType, width, height);
GImageMiscOps.fill(input, 1);
GIntegralImageOps.transform(input, integral);
double found = ((Number) m.invoke(null, integral, 4, 5, 8, 8)).doubleValue();
assertEquals(12, found, 1e-4f);
found = ((Number) m.invoke(null, integral, -1, -2, 2, 3)).doubleValue();
assertEquals(12, found, 1e-4f);
found = ((Number) m.invoke(null, integral, width - 2, height - 3, width + 1, height + 3)).doubleValue();
assertEquals(2, found, 1e-4f);
found = ((Number) m.invoke(null, integral, 3, -4, -1, -1)).doubleValue();
assertEquals(0, found, 1e-4f);
found = ((Number) m.invoke(null, integral, width + 1, height + 2, width + 6, height + 8)).doubleValue();
assertEquals(0, found, 1e-4f);
}
Aggregations