Search in sources :

Example 16 with GrayS32

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);
}
Also used : GrayS32(boofcv.struct.image.GrayS32)

Example 17 with GrayS32

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;
}
Also used : GrayS32(boofcv.struct.image.GrayS32)

Example 18 with GrayS32

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);
}
Also used : GrayU8(boofcv.struct.image.GrayU8) GrayS32(boofcv.struct.image.GrayS32)

Example 19 with GrayS32

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);
    }
}
Also used : BorderIndex1D(boofcv.core.image.border.BorderIndex1D) GrayS32(boofcv.struct.image.GrayS32)

Example 20 with GrayS32

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);
}
Also used : GImageGray(boofcv.core.image.GImageGray) FactoryGImageGray(boofcv.core.image.FactoryGImageGray) ImageGray(boofcv.struct.image.ImageGray) GrayS32(boofcv.struct.image.GrayS32)

Aggregations

GrayS32 (boofcv.struct.image.GrayS32)102 Test (org.junit.Test)79 GrayU8 (boofcv.struct.image.GrayU8)52 GrayF32 (boofcv.struct.image.GrayF32)13 GrowQueue_I32 (org.ddogleg.struct.GrowQueue_I32)10 Point2D_I32 (georegression.struct.point.Point2D_I32)7 FactoryGImageGray (boofcv.core.image.FactoryGImageGray)4 GImageGray (boofcv.core.image.GImageGray)4 ImageGray (boofcv.struct.image.ImageGray)4 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)3 ImageDimension (boofcv.struct.image.ImageDimension)3 BufferedImage (java.awt.image.BufferedImage)3 FastQueue (org.ddogleg.struct.FastQueue)3 WatershedVincentSoille1991 (boofcv.alg.segmentation.watershed.WatershedVincentSoille1991)2 IntegralKernel (boofcv.alg.transform.ii.IntegralKernel)2 ImageBorder_S32 (boofcv.core.image.border.ImageBorder_S32)2 ListDisplayPanel (boofcv.gui.ListDisplayPanel)2 ImageRectangle (boofcv.struct.ImageRectangle)2 PackedSetsPoint2D_I32 (boofcv.struct.PackedSetsPoint2D_I32)2 Kernel2D_S32 (boofcv.struct.convolve.Kernel2D_S32)2