Search in sources :

Example 31 with GrayF32

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

the class TestDistortSupport method distortScale.

@Test
public void distortScale() {
    GrayF32 a = new GrayF32(25, 30);
    GrayF32 b = new GrayF32(15, 25);
    PixelTransform2_F32 tran = DistortSupport.transformScale(a, b, null);
    // check edge cases at the image border
    tran.compute(0, 0);
    assertEquals(0, tran.distX, 1e-8);
    assertEquals(0, tran.distY, 1e-8);
    tran.compute(24, 29);
    assertEquals(24 * 15.0 / 25.0, tran.distX, 1e-4);
    assertEquals(29 * 25.0 / 30.0, tran.distY, 1e-4);
    // some point inside now
    tran.compute(5, 6);
    assertEquals(5.0 * 15.0 / 25.0, tran.distX, 1e-4);
    assertEquals(6.0 * 25.0 / 30.0, tran.distY, 1e-4);
}
Also used : GrayF32(boofcv.struct.image.GrayF32) PixelTransform2_F32(boofcv.struct.distort.PixelTransform2_F32) Test(org.junit.Test)

Example 32 with GrayF32

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

the class WrapSiftDetector method detect.

@Override
public void detect(T image) {
    GrayF32 input;
    if (image instanceof GrayF32) {
        input = (GrayF32) image;
    } else {
        imageFloat.reshape(image.width, image.height);
        GConvertImage.convert(image, imageFloat);
        input = imageFloat;
    }
    detector.process(input);
}
Also used : GrayF32(boofcv.struct.image.GrayF32)

Example 33 with GrayF32

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

the class FhEdgeWeights4_PLF32 method checkAround.

private void checkAround(int x, int y, Planar<GrayF32> input, FastQueue<Edge> edges) {
    int indexSrc = input.startIndex + y * input.stride + x;
    int indexA = y * input.width + x;
    for (int i = 0; i < numBands; i++) {
        GrayF32 band = input.getBand(i);
        pixelColor[i] = band.data[indexSrc];
    }
    check(x + 1, y, pixelColor, indexA, input, edges);
    check(x, y + 1, pixelColor, indexA, input, edges);
}
Also used : GrayF32(boofcv.struct.image.GrayF32)

Example 34 with GrayF32

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

the class FhEdgeWeights4_PLF32 method process.

@Override
public void process(Planar<GrayF32> input, FastQueue<Edge> edges) {
    edges.reset();
    int w = input.width - 1;
    int h = input.height - 1;
    // First consider the inner pixels
    for (int y = 0; y < h; y++) {
        int indexSrc = input.startIndex + y * input.stride + 0;
        int indexDst = +y * input.width + 0;
        for (int x = 0; x < w; x++, indexSrc++, indexDst++) {
            float weight1 = 0, weight2 = 0;
            for (int i = 0; i < numBands; i++) {
                GrayF32 band = input.getBand(i);
                // (x,y)
                float color0 = band.data[indexSrc];
                // (x+1,y)
                float color1 = band.data[indexSrc + 1];
                // (x,y+1)
                float color2 = band.data[indexSrc + input.stride];
                float diff1 = color0 - color1;
                float diff2 = color0 - color2;
                weight1 += diff1 * diff1;
                weight2 += diff2 * diff2;
            }
            Edge e1 = edges.grow();
            Edge e2 = edges.grow();
            e1.sortValue = (float) Math.sqrt(weight1);
            e1.indexA = indexDst;
            e1.indexB = indexDst + 1;
            e2.sortValue = (float) Math.sqrt(weight2);
            e2.indexA = indexDst;
            e2.indexB = indexDst + input.width;
        }
    }
    // Handle border pixels
    for (int y = 0; y < h; y++) {
        checkAround(w, y, input, edges);
    }
    for (int x = 0; x < w; x++) {
        checkAround(x, h, input, edges);
    }
}
Also used : GrayF32(boofcv.struct.image.GrayF32) Edge(boofcv.alg.segmentation.fh04.SegmentFelzenszwalbHuttenlocher04.Edge)

Example 35 with GrayF32

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

the class FhEdgeWeights8_PLF32 method checkAround.

private void checkAround(int x, int y, Planar<GrayF32> input, FastQueue<Edge> edges) {
    int indexSrc = input.startIndex + y * input.stride + x;
    int indexA = y * input.width + x;
    for (int i = 0; i < numBands; i++) {
        GrayF32 band = input.getBand(i);
        pixelColor[i] = band.data[indexSrc];
    }
    check(x + 1, y, pixelColor, indexA, input, edges);
    check(x, y + 1, pixelColor, indexA, input, edges);
    check(x + 1, y + 1, pixelColor, indexA, input, edges);
    check(x - 1, y + 1, pixelColor, indexA, input, edges);
}
Also used : GrayF32(boofcv.struct.image.GrayF32)

Aggregations

GrayF32 (boofcv.struct.image.GrayF32)530 Test (org.junit.Test)291 BufferedImage (java.awt.image.BufferedImage)81 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)76 GrayU8 (boofcv.struct.image.GrayU8)49 Planar (boofcv.struct.image.Planar)34 ArrayList (java.util.ArrayList)28 ImageBorder_F32 (boofcv.core.image.border.ImageBorder_F32)20 ImageGray (boofcv.struct.image.ImageGray)20 File (java.io.File)20 CameraPinholeRadial (boofcv.struct.calib.CameraPinholeRadial)19 Se3_F64 (georegression.struct.se.Se3_F64)18 TupleDesc_F64 (boofcv.struct.feature.TupleDesc_F64)17 GrayS8 (boofcv.struct.image.GrayS8)16 ListDisplayPanel (boofcv.gui.ListDisplayPanel)14 PathLabel (boofcv.io.PathLabel)14 Kernel2D_F32 (boofcv.struct.convolve.Kernel2D_F32)13 GrayS16 (boofcv.struct.image.GrayS16)13 GrayS32 (boofcv.struct.image.GrayS32)13 Point2D_F64 (georegression.struct.point.Point2D_F64)13