Search in sources :

Example 1 with KernelBase

use of boofcv.struct.convolve.KernelBase in project BoofCV by lessthanoptimal.

the class GImageDerivativeOps method createAnyDerivatives.

/**
 * <p>
 * Convenience function for creating an instance of {@link boofcv.abst.filter.derivative.AnyImageDerivative}.
 * This class is an any way to compute any derivative of any order using the specified kernel.  It might
 * use more memory or be more expensive the specialized code but is easy to use.
 * </p>
 *
 * @param type Type of gradient to use
 * @param inputType Type of input image.
 * @param derivType Type of derivative image
 * @param <I> Image type.
 * @param <D> Image derivative type.
 * @return AnyImageDerivative
 */
public static <I extends ImageGray<I>, D extends ImageGray<D>> AnyImageDerivative<I, D> createAnyDerivatives(DerivativeType type, Class<I> inputType, Class<D> derivType) {
    boolean isInteger = !GeneralizedImageOps.isFloatingPoint(inputType);
    KernelBase kernel = lookupKernelX(type, isInteger);
    if (kernel instanceof Kernel1D)
        return new AnyImageDerivative<>((Kernel1D) kernel, inputType, derivType);
    else
        return new AnyImageDerivative<>((Kernel2D) kernel, inputType, derivType);
}
Also used : Kernel1D(boofcv.struct.convolve.Kernel1D) KernelBase(boofcv.struct.convolve.KernelBase) Kernel2D(boofcv.struct.convolve.Kernel2D)

Example 2 with KernelBase

use of boofcv.struct.convolve.KernelBase in project BoofCV by lessthanoptimal.

the class TestConvolveJustBorder_General_SB method createInputParam.

@Override
protected Object[][] createInputParam(Method candidate, Method validation) {
    Class<?>[] paramTypes = candidate.getParameterTypes();
    KernelBase kernel = createKernel(paramTypes[0], kernelWidth, kernelWidth / 2);
    ImageBase src = ConvolutionTestHelper.createImage(validation.getParameterTypes()[1], width, height);
    GImageMiscOps.fillUniform(src, rand, 0, 5);
    ImageBase dst = ConvolutionTestHelper.createImage(validation.getParameterTypes()[2], width, height);
    Object[][] ret = new Object[2][paramTypes.length];
    // normal symmetric odd kernel
    ret[0][0] = kernel;
    ret[0][1] = GrayF32.class == src.getClass() ? ImageBorderValue.wrap((GrayF32) src, fillValue) : ImageBorderValue.wrap((GrayI) src, fillValue);
    ret[0][2] = dst;
    // change the offset
    kernel = createKernel(paramTypes[0], kernelWidth, kernelWidth / 2 - 1);
    ret[1][0] = kernel;
    ret[1][1] = GrayF32.class == src.getClass() ? ImageBorderValue.wrap((GrayF32) src, fillValue) : ImageBorderValue.wrap((GrayI) src, fillValue);
    ret[1][2] = ConvolutionTestHelper.createImage(validation.getParameterTypes()[2], width, height);
    return ret;
}
Also used : KernelBase(boofcv.struct.convolve.KernelBase) ImageBase(boofcv.struct.image.ImageBase)

Example 3 with KernelBase

use of boofcv.struct.convolve.KernelBase in project BoofCV by lessthanoptimal.

the class TestConvolveImage method reformatForValidation.

@Override
protected Object[] reformatForValidation(Method m, Object[] targetParam) {
    Object[] ret = new Object[] { targetParam[0], targetParam[1], targetParam[2] };
    ImageBase inputImage = (ImageBase) targetParam[1];
    KernelBase kernel = (KernelBase) targetParam[0];
    computeBorder(kernel, m.getName());
    int w = borderX0 + borderX1;
    int h = borderY0 + borderY1;
    ret[1] = inputImage.createNew(width + w, height + h);
    ret[2] = ((ImageBase) targetParam[2]).createNew(width + w, height + h);
    fillTestImage(inputImage, (ImageBase) ret[1], kernel, m.getName());
    return ret;
}
Also used : KernelBase(boofcv.struct.convolve.KernelBase) ImageBase(boofcv.struct.image.ImageBase)

Example 4 with KernelBase

use of boofcv.struct.convolve.KernelBase in project BoofCV by lessthanoptimal.

the class TestConvolveJustBorder_General_IL method reformatForValidation.

@Override
protected Object[] reformatForValidation(Method m, Object[] targetParam) {
    Object[] ret = new Object[] { targetParam[0], targetParam[1], targetParam[2] };
    ImageInterleaved inputImage = (ImageInterleaved) ((ImageBorder) targetParam[1]).getImage();
    KernelBase kernel = (KernelBase) targetParam[0];
    computeBorder(kernel, m.getName());
    int borderW = borderX0 + borderX1;
    int borderH = borderY0 + borderY1;
    ret[1] = inputImage.createNew(width + borderW, height + borderH);
    ret[2] = ((ImageInterleaved) targetParam[2]).createNew(width + borderW, height + borderH);
    fillTestImage(inputImage, (ImageInterleaved) ret[1], borderX0, borderY0, borderX1, borderY1);
    return ret;
}
Also used : ImageInterleaved(boofcv.struct.image.ImageInterleaved) KernelBase(boofcv.struct.convolve.KernelBase)

Example 5 with KernelBase

use of boofcv.struct.convolve.KernelBase in project BoofCV by lessthanoptimal.

the class TestConvolveJustBorder_General_IL method createInputParam.

@Override
protected Object[][] createInputParam(Method candidate, Method validation) {
    Class<?>[] paramTypes = candidate.getParameterTypes();
    KernelBase kernel = createKernel(paramTypes[0], kernelWidth, kernelWidth / 2);
    ImageBase src = ConvolutionTestHelper.createImage(validation.getParameterTypes()[1], width, height);
    GImageMiscOps.fillUniform(src, rand, 0, 5);
    ImageBase dst = ConvolutionTestHelper.createImage(validation.getParameterTypes()[2], width, height);
    Object[][] ret = new Object[2][paramTypes.length];
    // normal symmetric odd kernel
    ret[0][0] = kernel;
    ret[0][1] = InterleavedF32.class == src.getClass() ? ImageBorderValue.wrap((InterleavedF32) src, fillValue) : ImageBorderValue.wrap((InterleavedInteger) src, fillValue);
    ret[0][2] = dst;
    // change the offset
    kernel = createKernel(paramTypes[0], kernelWidth, kernelWidth / 2 - 1);
    ret[1][0] = kernel;
    ret[1][1] = InterleavedF32.class == src.getClass() ? ImageBorderValue.wrap((InterleavedF32) src, fillValue) : ImageBorderValue.wrap((InterleavedInteger) src, fillValue);
    ret[1][2] = ConvolutionTestHelper.createImage(validation.getParameterTypes()[2], width, height);
    return ret;
}
Also used : KernelBase(boofcv.struct.convolve.KernelBase) ImageBase(boofcv.struct.image.ImageBase)

Aggregations

KernelBase (boofcv.struct.convolve.KernelBase)6 ImageBase (boofcv.struct.image.ImageBase)3 FactoryGImageGray (boofcv.core.image.FactoryGImageGray)1 GImageGray (boofcv.core.image.GImageGray)1 Kernel1D (boofcv.struct.convolve.Kernel1D)1 Kernel2D (boofcv.struct.convolve.Kernel2D)1 ImageGray (boofcv.struct.image.ImageGray)1 ImageInterleaved (boofcv.struct.image.ImageInterleaved)1