Search in sources :

Example 26 with GrayS16

use of boofcv.struct.image.GrayS16 in project BoofCV by lessthanoptimal.

the class TestCannyEdgeDynamic method canHandleNoTexture.

/**
 * Test the pathological case where the input image has no texture.  The threshold will be zero and the
 * edge intensity will be zero everywhere.
 */
@Test
public void canHandleNoTexture() {
    GrayU8 input = new GrayU8(width, height);
    GrayU8 output = new GrayU8(width, height);
    ImageMiscOps.fill(output, 2);
    CannyEdge<GrayU8, GrayS16> alg = FactoryEdgeDetectors.canny(2, false, true, GrayU8.class, GrayS16.class);
    alg.process(input, 0.075f, 0.3f, output);
    for (int i = 0; i < output.data.length; i++) {
        assertEquals(0, output.data[i]);
    }
    // try it with a trace now
    alg = FactoryEdgeDetectors.canny(2, true, true, GrayU8.class, GrayS16.class);
    ImageMiscOps.fill(output, 2);
    alg.process(input, 0.075f, 0.3f, output);
    List<EdgeContour> contour = alg.getContours();
    assertTrue(contour.size() == 0);
    for (int i = 0; i < output.data.length; i++) assertEquals(0, output.data[i]);
}
Also used : GrayS16(boofcv.struct.image.GrayS16) GrayU8(boofcv.struct.image.GrayU8) Test(org.junit.Test)

Example 27 with GrayS16

use of boofcv.struct.image.GrayS16 in project BoofCV by lessthanoptimal.

the class TestCannyEdgeDynamic method basicTestPoints.

/**
 * Just checks to see if it computes a reasonable threshold given fractional parameters
 */
@Test
public void basicTestPoints() {
    GrayU8 input = new GrayU8(width, height);
    ImageMiscOps.fillRectangle(input, 50, 20, 30, 40, 50);
    BlurFilter<GrayU8> blur = FactoryBlurFilter.gaussian(ImageType.single(GrayU8.class), -1, 1);
    ImageGradient<GrayU8, GrayS16> gradient = FactoryDerivative.sobel(GrayU8.class, GrayS16.class);
    CannyEdgeDynamic<GrayU8, GrayS16> alg = new CannyEdgeDynamic<>(blur, gradient, true);
    alg.process(input, 0.2f, 0.4f, null);
    List<EdgeContour> contour = alg.getContours();
    int totalPass = 0;
    for (EdgeContour e : contour) {
        int total = 0;
        for (EdgeSegment s : e.segments) {
            // really should check to see if the points are near the rectangle....
            total += s.points.size();
        }
        if (total >= 2 * 50 + 2 * 38)
            totalPass++;
    }
    assertEquals(1, totalPass);
}
Also used : GrayS16(boofcv.struct.image.GrayS16) GrayU8(boofcv.struct.image.GrayU8) Test(org.junit.Test)

Example 28 with GrayS16

use of boofcv.struct.image.GrayS16 in project BoofCV by lessthanoptimal.

the class BenchmarkSsdCornerIntensity method main.

public static void main(String[] args) {
    derivX_F32 = new GrayF32(imgWidth, imgHeight);
    derivY_F32 = new GrayF32(imgWidth, imgHeight);
    derivXX_F32 = new GrayF32(imgWidth, imgHeight);
    derivYY_F32 = new GrayF32(imgWidth, imgHeight);
    derivXY_F32 = new GrayF32(imgWidth, imgHeight);
    derivX_I16 = new GrayS16(imgWidth, imgHeight);
    derivY_I16 = new GrayS16(imgWidth, imgHeight);
    derivXX_I16 = new GrayS16(imgWidth, imgHeight);
    derivYY_I16 = new GrayS16(imgWidth, imgHeight);
    derivXY_I16 = new GrayS16(imgWidth, imgHeight);
    ImageMiscOps.fillUniform(derivX_F32, rand, 0, 255);
    ImageMiscOps.fillUniform(derivY_F32, rand, 0, 255);
    ImageMiscOps.fillUniform(derivXX_F32, rand, 0, 255);
    ImageMiscOps.fillUniform(derivYY_F32, rand, 0, 255);
    ImageMiscOps.fillUniform(derivXY_F32, rand, 0, 255);
    ImageMiscOps.fillUniform(derivX_I16, rand, 0, 255);
    ImageMiscOps.fillUniform(derivY_I16, rand, 0, 255);
    ImageMiscOps.fillUniform(derivXX_I16, rand, 0, 255);
    ImageMiscOps.fillUniform(derivYY_I16, rand, 0, 255);
    ImageMiscOps.fillUniform(derivXY_I16, rand, 0, 255);
    System.out.println("=========  Profile Image Size " + imgWidth + " x " + imgHeight + " ==========");
    System.out.println();
    ProfileOperation.printOpsPerSec(new KLT_F32(), TEST_TIME);
    ProfileOperation.printOpsPerSec(new KLT_WEIGHT_F32(), TEST_TIME);
    ProfileOperation.printOpsPerSec(new Harris_F32(), TEST_TIME);
    ProfileOperation.printOpsPerSec(new KitRos_F32(), TEST_TIME);
    ProfileOperation.printOpsPerSec(new KLT_I16(), TEST_TIME);
    ProfileOperation.printOpsPerSec(new KLT_WEIGHT_I16(), TEST_TIME);
    ProfileOperation.printOpsPerSec(new Harris_I16(), TEST_TIME);
    ProfileOperation.printOpsPerSec(new KitRos_I16(), TEST_TIME);
    ProfileOperation.printOpsPerSec(new KLT_Naive_I16(), TEST_TIME);
}
Also used : GrayF32(boofcv.struct.image.GrayF32) GrayS16(boofcv.struct.image.GrayS16)

Example 29 with GrayS16

use of boofcv.struct.image.GrayS16 in project BoofCV by lessthanoptimal.

the class BenchmarkDerivativeBase method process.

public void process() {
    imgInt8 = new GrayU8(imgWidth, imgHeight);
    derivX_I16 = new GrayS16(imgWidth, imgHeight);
    derivY_I16 = new GrayS16(imgWidth, imgHeight);
    derivXY_I16 = new GrayS16(imgWidth, imgHeight);
    imgFloat32 = new GrayF32(imgWidth, imgHeight);
    derivX_F32 = new GrayF32(imgWidth, imgHeight);
    derivY_F32 = new GrayF32(imgWidth, imgHeight);
    derivXY_F32 = new GrayF32(imgWidth, imgHeight);
    Random rand = new Random(123);
    GImageMiscOps.fillUniform(imgInt8, rand, 0, 100);
    GImageMiscOps.fillUniform(imgFloat32, rand, 0, 100);
    System.out.println("=========  Profile Image Size " + imgWidth + " x " + imgHeight + " ==========");
    System.out.println("               border = " + border);
    System.out.println();
    System.out.println("             GrayU8");
    System.out.println();
    profile_I8();
    System.out.println("\n             GrayF32");
    System.out.println();
    profile_F32();
}
Also used : GrayF32(boofcv.struct.image.GrayF32) Random(java.util.Random) GrayS16(boofcv.struct.image.GrayS16) GrayU8(boofcv.struct.image.GrayU8)

Example 30 with GrayS16

use of boofcv.struct.image.GrayS16 in project BoofCV by lessthanoptimal.

the class TestFactoryDerivativeSparse method laplacian_I.

@Test
public void laplacian_I() {
    GrayU8 input = new GrayU8(width, height);
    GrayS16 expected = new GrayS16(width, height);
    GImageMiscOps.fillUniform(input, rand, 0, 20);
    LaplacianEdge.process(input, expected);
    ImageFunctionSparse<GrayU8> func = FactoryDerivativeSparse.createLaplacian(GrayU8.class, null);
    func.setImage(input);
    double found = func.compute(6, 8);
    assertEquals(expected.get(6, 8), found, 1e-4);
}
Also used : GrayS16(boofcv.struct.image.GrayS16) GrayU8(boofcv.struct.image.GrayU8) Test(org.junit.Test)

Aggregations

GrayS16 (boofcv.struct.image.GrayS16)63 GrayU8 (boofcv.struct.image.GrayU8)45 Test (org.junit.Test)39 ImageBorder_S32 (boofcv.core.image.border.ImageBorder_S32)15 GrayF32 (boofcv.struct.image.GrayF32)13 Random (java.util.Random)8 CompareDerivativeToConvolution (boofcv.alg.filter.derivative.CompareDerivativeToConvolution)7 BorderIndex1D_Extend (boofcv.core.image.border.BorderIndex1D_Extend)4 ImageBorder1D_S32 (boofcv.core.image.border.ImageBorder1D_S32)4 ImageGray (boofcv.struct.image.ImageGray)4 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)3 BufferedImage (java.awt.image.BufferedImage)3 WrapDisparitySadRect (boofcv.abst.feature.disparity.WrapDisparitySadRect)2 DisparitySelect (boofcv.alg.feature.disparity.DisparitySelect)2 ImageBorder_F32 (boofcv.core.image.border.ImageBorder_F32)2 ListDisplayPanel (boofcv.gui.ListDisplayPanel)2 Kernel1D_S32 (boofcv.struct.convolve.Kernel1D_S32)2 FDistort (boofcv.abst.distort.FDistort)1 DetectLineSegmentsGridRansac (boofcv.abst.feature.detect.line.DetectLineSegmentsGridRansac)1 EdgeContour (boofcv.alg.feature.detect.edge.EdgeContour)1