Search in sources :

Example 1 with ImageGradient

use of boofcv.abst.filter.derivative.ImageGradient in project BoofCV by lessthanoptimal.

the class GeneralGradientSparse method compareToFullImage_Border.

@Test
public void compareToFullImage_Border() {
    ImageBorder border = FactoryImageBorder.single(imageType, BorderType.EXTENDED);
    ImageGradient gradient = createGradient();
    gradient.setBorderType(BorderType.EXTENDED);
    gradient.process(image, derivX, derivY);
    SparseImageGradient alg = createAlg(border);
    alg.setImage(image);
    for (int i = 0; i < image.height; i++) {
        for (int j = 0; j < image.width; j++) {
            assertTrue(j + " " + i, image.isInBounds(j, i));
            GradientValue g = alg.compute(j, i);
            double expectedX = GeneralizedImageOps.get(derivX, j, i);
            double expectedY = GeneralizedImageOps.get(derivY, j, i);
            assertEquals(expectedX, g.getX(), 1e-4f);
            assertEquals(expectedY, g.getY(), 1e-4f);
        }
    }
}
Also used : SparseImageGradient(boofcv.struct.sparse.SparseImageGradient) GradientValue(boofcv.struct.sparse.GradientValue) ImageBorder(boofcv.core.image.border.ImageBorder) FactoryImageBorder(boofcv.core.image.border.FactoryImageBorder) ImageGradient(boofcv.abst.filter.derivative.ImageGradient) SparseImageGradient(boofcv.struct.sparse.SparseImageGradient) Test(org.junit.Test)

Example 2 with ImageGradient

use of boofcv.abst.filter.derivative.ImageGradient in project BoofCV by lessthanoptimal.

the class TestSfot_to_TrackObjectQuad method create.

@Override
public TrackerObjectQuad<GrayU8> create(ImageType<GrayU8> imageType) {
    Class ct = ImageDataType.typeToSingleClass(imageType.getDataType());
    Class dt = GImageDerivativeOps.getDerivativeType(ct);
    ImageGradient gradient = FactoryDerivative.sobel(ct, dt);
    SfotConfig config = new SfotConfig();
    SparseFlowObjectTracker tracker = new SparseFlowObjectTracker(config, ct, dt, gradient);
    return new Sfot_to_TrackObjectQuad(tracker, ct);
}
Also used : SfotConfig(boofcv.alg.tracker.sfot.SfotConfig) SparseFlowObjectTracker(boofcv.alg.tracker.sfot.SparseFlowObjectTracker) ImageGradient(boofcv.abst.filter.derivative.ImageGradient)

Example 3 with ImageGradient

use of boofcv.abst.filter.derivative.ImageGradient in project BoofCV by lessthanoptimal.

the class FactoryOrientation method convertImage.

/**
 * Adds wrappers around implementations of {@link RegionOrientation} such that they can be used
 * as a {@link OrientationImage}.
 *
 * @param algorithm Algorithm which takes in a different type of input.
 * @param imageType Type of input image it will process
 * @return Wrapped version which can process images as its raw input.
 */
public static <T extends ImageGray<T>> OrientationImage<T> convertImage(RegionOrientation algorithm, Class<T> imageType) {
    if (algorithm instanceof OrientationGradient) {
        Class derivType = ((OrientationGradient) algorithm).getImageType();
        ImageGradient gradient = FactoryDerivative.sobel(imageType, derivType);
        return new OrientationGradientToImage((OrientationGradient) algorithm, gradient, imageType, derivType);
    } else if (algorithm instanceof OrientationIntegral) {
        Class integralType = GIntegralImageOps.getIntegralType(imageType);
        return new OrientationIntegralToImage((OrientationIntegral) algorithm, imageType, integralType);
    } else {
        throw new IllegalArgumentException("Unknown orientation algorithm type");
    }
}
Also used : ImageGradient(boofcv.abst.filter.derivative.ImageGradient)

Aggregations

ImageGradient (boofcv.abst.filter.derivative.ImageGradient)3 SfotConfig (boofcv.alg.tracker.sfot.SfotConfig)1 SparseFlowObjectTracker (boofcv.alg.tracker.sfot.SparseFlowObjectTracker)1 FactoryImageBorder (boofcv.core.image.border.FactoryImageBorder)1 ImageBorder (boofcv.core.image.border.ImageBorder)1 GradientValue (boofcv.struct.sparse.GradientValue)1 SparseImageGradient (boofcv.struct.sparse.SparseImageGradient)1 Test (org.junit.Test)1