Search in sources :

Example 11 with GrayF32

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

the class TestGeneralToInterestMulti method various.

/**
 * Several basic functionality tests
 */
public void various() {
    Helper detector = new Helper();
    detector.maximum = true;
    GeneralToInterestMulti<GrayF32, GrayF32> alg = new GeneralToInterestMulti<>(detector, 2.5, GrayF32.class, GrayF32.class);
    alg.detect(input);
    assertEquals(1, alg.getNumberOfSets());
    FoundPointSO set = alg.getFeatureSet(0);
    assertEquals(6, set.getNumberOfFeatures());
    for (int i = 0; i < set.getNumberOfFeatures(); i++) {
        assertEquals(2.5, set.getRadius(i), 1e-8);
        assertEquals(0, set.getOrientation(i), 1e-8);
    }
    assertEquals(1, detector.calledProcess);
    assertEquals(6, detector.getMaximums().size);
}
Also used : Helper(boofcv.abst.feature.detect.interest.TestGeneralToInterestPoint.Helper) GrayF32(boofcv.struct.image.GrayF32)

Example 12 with GrayF32

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

the class WaveletTransformFloat32 method transform.

@Override
public GrayF32 transform(GrayF32 original, GrayF32 transformed) {
    if (transformed == null) {
        ImageDimension d = UtilWavelet.transformDimension(original, numLevels);
        transformed = new GrayF32(d.width, d.height);
    }
    temp.reshape(transformed.width, transformed.height);
    copy.reshape(original.width, original.height);
    copy.setTo(original);
    WaveletTransformOps.transformN(desc, copy, transformed, temp, numLevels);
    return transformed;
}
Also used : GrayF32(boofcv.struct.image.GrayF32) ImageDimension(boofcv.struct.image.ImageDimension)

Example 13 with GrayF32

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

the class ColorHsv method hsvToRgb_F32.

/**
 * Converts an image from HSV into RGB.
 *
 * @param hsv (Input) Image in HSV format
 * @param rgb (Output) Image in RGB format
 */
public static void hsvToRgb_F32(Planar<GrayF32> hsv, Planar<GrayF32> rgb) {
    InputSanityCheck.checkSameShape(hsv, rgb);
    GrayF32 H = hsv.getBand(0);
    GrayF32 S = hsv.getBand(1);
    GrayF32 V = hsv.getBand(2);
    GrayF32 R = rgb.getBand(0);
    GrayF32 G = rgb.getBand(1);
    GrayF32 B = rgb.getBand(2);
    for (int row = 0; row < hsv.height; row++) {
        int indexHsv = hsv.startIndex + row * hsv.stride;
        int indexRgb = rgb.startIndex + row * rgb.stride;
        for (int col = 0; col < hsv.width; col++, indexHsv++, indexRgb++) {
            float h = H.data[indexHsv];
            float s = S.data[indexHsv];
            float v = V.data[indexHsv];
            if (s == 0) {
                R.data[indexRgb] = v;
                G.data[indexRgb] = v;
                B.data[indexRgb] = v;
                continue;
            }
            h /= d60_F32;
            int h_int = (int) h;
            float remainder = h - h_int;
            float p = v * (1 - s);
            float q = v * (1 - s * remainder);
            float t = v * (1 - s * (1 - remainder));
            if (h_int < 1) {
                R.data[indexRgb] = v;
                G.data[indexRgb] = t;
                B.data[indexRgb] = p;
            } else if (h_int < 2) {
                R.data[indexRgb] = q;
                G.data[indexRgb] = v;
                B.data[indexRgb] = p;
            } else if (h_int < 3) {
                R.data[indexRgb] = p;
                G.data[indexRgb] = v;
                B.data[indexRgb] = t;
            } else if (h_int < 4) {
                R.data[indexRgb] = p;
                G.data[indexRgb] = q;
                B.data[indexRgb] = v;
            } else if (h_int < 5) {
                R.data[indexRgb] = t;
                G.data[indexRgb] = p;
                B.data[indexRgb] = v;
            } else {
                R.data[indexRgb] = v;
                G.data[indexRgb] = p;
                B.data[indexRgb] = q;
            }
        }
    }
}
Also used : GrayF32(boofcv.struct.image.GrayF32)

Example 14 with GrayF32

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

the class ColorXyz method rgbToXyz_F32.

/**
 * Convert a 3-channel {@link Planar} image from RGB into XYZ.  RGB is assumed
 * to have a range from 0:255
 *
 * NOTE: Input and output image can be the same instance.
 *
 * @param rgb (Input) RGB encoded image
 * @param xyz (Output) XYZ encoded image
 */
public static void rgbToXyz_F32(Planar<GrayF32> rgb, Planar<GrayF32> xyz) {
    InputSanityCheck.checkSameShape(xyz, rgb);
    GrayF32 R = rgb.getBand(0);
    GrayF32 G = rgb.getBand(1);
    GrayF32 B = rgb.getBand(2);
    GrayF32 X = xyz.getBand(0);
    GrayF32 Y = xyz.getBand(1);
    GrayF32 Z = xyz.getBand(2);
    for (int row = 0; row < xyz.height; row++) {
        int indexXyz = xyz.startIndex + row * xyz.stride;
        int indexRgb = rgb.startIndex + row * rgb.stride;
        for (int col = 0; col < xyz.width; col++, indexXyz++, indexRgb++) {
            float r = R.data[indexRgb] / 255f;
            float g = G.data[indexRgb] / 255f;
            float b = B.data[indexRgb] / 255f;
            X.data[indexXyz] = 0.412453f * r + 0.35758f * g + 0.180423f * b;
            Y.data[indexXyz] = 0.212671f * r + 0.71516f * g + 0.072169f * b;
            Z.data[indexXyz] = 0.019334f * r + 0.119193f * g + 0.950227f * b;
        }
    }
}
Also used : GrayF32(boofcv.struct.image.GrayF32)

Example 15 with GrayF32

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

the class ColorYuv method rgbToYuv_F32.

/**
 * Convert a 3-channel {@link Planar} image from RGB into YUV.
 *
 * NOTE: Input and output image can be the same instance.
 *
 * @param rgb (Input) RGB encoded image
 * @param yuv (Output) YUV encoded image
 */
public static void rgbToYuv_F32(Planar<GrayF32> rgb, Planar<GrayF32> yuv) {
    InputSanityCheck.checkSameShape(yuv, rgb);
    GrayF32 R = rgb.getBand(0);
    GrayF32 G = rgb.getBand(1);
    GrayF32 B = rgb.getBand(2);
    GrayF32 Y = yuv.getBand(0);
    GrayF32 U = yuv.getBand(1);
    GrayF32 V = yuv.getBand(2);
    for (int row = 0; row < yuv.height; row++) {
        int indexYuv = yuv.startIndex + row * yuv.stride;
        int indexRgb = rgb.startIndex + row * rgb.stride;
        for (int col = 0; col < yuv.width; col++, indexYuv++, indexRgb++) {
            float r = R.data[indexRgb];
            float g = G.data[indexRgb];
            float b = B.data[indexRgb];
            float y = 0.299f * r + 0.587f * g + 0.114f * b;
            Y.data[indexYuv] = y;
            U.data[indexYuv] = 0.492f * (b - y);
            V.data[indexYuv] = 0.877f * (r - y);
        }
    }
}
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