Search in sources :

Example 46 with ImageGray

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

the class TestConvolveImageMean method createInputParam.

@Override
protected Object[][] createInputParam(Method candidate, Method validation) {
    Class[] c = candidate.getParameterTypes();
    ImageGray input = GeneralizedImageOps.createSingleBand(c[0], width, height);
    ImageGray output = GeneralizedImageOps.createSingleBand(c[1], width, height);
    GImageMiscOps.fillUniform(input, rand, 0, 100);
    Object[][] ret = new Object[2][];
    ret[0] = new Object[] { input, output, kernelRadius };
    ret[1] = new Object[] { input, output, kernelRadius2 };
    return ret;
}
Also used : ImageGray(boofcv.struct.image.ImageGray)

Example 47 with ImageGray

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

the class TestConvolveJustBorder_General_SB method compareResults.

@Override
protected void compareResults(Object targetResult, Object[] targetParam, Object validationResult, Object[] validationParam) {
    ImageGray targetOut = (ImageGray) targetParam[2];
    ImageGray validationOut = (ImageGray) validationParam[2];
    // remove the border
    computeBorder((KernelBase) targetParam[0], methodTest.getName());
    validationOut = (ImageGray) stripBorder(validationOut, borderX0, borderY0, borderX1, borderY1);
    GImageGray t = FactoryGImageGray.wrap(targetOut);
    GImageGray v = FactoryGImageGray.wrap(validationOut);
    for (int y = 0; y < targetOut.height; y++) {
        if (y >= borderX0 && y < targetOut.height - borderX1)
            continue;
        for (int x = 0; x < targetOut.width; x++) {
            if (x >= borderX0 && x < targetOut.width - borderY1)
                continue;
            assertEquals(x + " " + y, v.get(x, y).doubleValue(), t.get(x, y).doubleValue(), 1e-4f);
        }
    }
}
Also used : GImageGray(boofcv.core.image.GImageGray) FactoryGImageGray(boofcv.core.image.FactoryGImageGray) GImageGray(boofcv.core.image.GImageGray) FactoryGImageGray(boofcv.core.image.FactoryGImageGray) ImageGray(boofcv.struct.image.ImageGray)

Example 48 with ImageGray

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

the class BatchDownSizeImage method main.

public static void main(String[] args) {
    parseArguments(args);
    ImageBase input = new GrayU8(1, 1);
    ImageBase small = null;
    int index = 0;
    int numDigits = BoofMiscOps.numDigits(images.size() - 1);
    String format = "%" + numDigits + "d";
    String format0 = "%0" + numDigits + "d";
    for (File f : images) {
        BufferedImage orig = UtilImageIO.loadImage(f.getPath());
        WritableRaster info = orig.getRaster();
        boolean missMatch = false;
        if (input.getWidth() != info.getWidth() || input.getHeight() != info.getHeight()) {
            missMatch = true;
        }
        if (info.getNumBands() == 1) {
            if (!(input instanceof ImageGray))
                missMatch = true;
        } else {
            if (!(input instanceof Planar)) {
                missMatch = true;
            } else if (info.getNumBands() != ((Planar) input).getNumBands()) {
                missMatch = true;
            }
        }
        if (missMatch) {
            // declare the BoofCV image to conver the input into
            if (info.getNumBands() == 1) {
                input = new GrayU8(info.getWidth(), info.getHeight());
            } else {
                input = new Planar<>(GrayU8.class, info.getWidth(), info.getHeight(), info.getNumBands());
            }
            // Now declare storage for the small image
            int smallHeight, smallWidth;
            if (useSide) {
                if (input.getWidth() > input.getHeight()) {
                    width = side;
                    height = 0;
                } else {
                    height = side;
                    width = 0;
                }
            }
            if (height == 0) {
                smallWidth = width;
                smallHeight = input.getHeight() * width / input.getWidth();
            } else if (width == 0) {
                smallWidth = input.getWidth() * height / input.getHeight();
                smallHeight = height;
            } else {
                smallWidth = width;
                smallHeight = height;
            }
            small = input.createNew(smallWidth, smallHeight);
        }
        System.out.printf(" " + format + " out of " + format + "   %s\n", index + 1, images.size(), f.getName());
        ConvertBufferedImage.convertFrom(orig, input, true);
        AverageDownSampleOps.down(input, small);
        String nout;
        if (rename) {
            nout = String.format("image" + format0 + ".png", index);
        } else {
            nout = f.getName();
            nout = nout.substring(0, nout.length() - 3) + "png";
        }
        File fout = new File(outputDir, nout);
        UtilImageIO.saveImage(small, fout.getPath());
        index++;
    }
    System.out.println("Done");
}
Also used : WritableRaster(java.awt.image.WritableRaster) Planar(boofcv.struct.image.Planar) GrayU8(boofcv.struct.image.GrayU8) ImageGray(boofcv.struct.image.ImageGray) File(java.io.File) ImageBase(boofcv.struct.image.ImageBase) BufferedImage(java.awt.image.BufferedImage) ConvertBufferedImage(boofcv.io.image.ConvertBufferedImage)

Example 49 with ImageGray

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

the class TestGradientToEdgeFeatures method intensityE.

public void intensityE(Method m) {
    Class[] params = m.getParameterTypes();
    ImageGray derivX = GeneralizedImageOps.createSingleBand(params[0], width, height);
    ImageGray derivY = GeneralizedImageOps.createSingleBand(params[0], width, height);
    GImageMiscOps.fillUniform(derivX, rand, 0, 10);
    GImageMiscOps.fillUniform(derivY, rand, 0, 10);
    BoofTesting.checkSubImage(this, "intensityE", true, m, derivX, derivY, intensity);
}
Also used : GImageGray(boofcv.core.image.GImageGray) FactoryGImageGray(boofcv.core.image.FactoryGImageGray) ImageGray(boofcv.struct.image.ImageGray)

Example 50 with ImageGray

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

the class TestGradientToEdgeFeatures method intensityAbs.

public void intensityAbs(Method m) {
    Class[] params = m.getParameterTypes();
    ImageGray derivX = GeneralizedImageOps.createSingleBand(params[0], width, height);
    ImageGray derivY = GeneralizedImageOps.createSingleBand(params[0], width, height);
    GImageMiscOps.fillUniform(derivX, rand, 0, 10);
    GImageMiscOps.fillUniform(derivY, rand, 0, 10);
    BoofTesting.checkSubImage(this, "intensityAbs", true, m, derivX, derivY, intensity);
}
Also used : GImageGray(boofcv.core.image.GImageGray) FactoryGImageGray(boofcv.core.image.FactoryGImageGray) ImageGray(boofcv.struct.image.ImageGray)

Aggregations

ImageGray (boofcv.struct.image.ImageGray)110 FactoryGImageGray (boofcv.core.image.FactoryGImageGray)43 GImageGray (boofcv.core.image.GImageGray)43 Test (org.junit.Test)26 GrayF32 (boofcv.struct.image.GrayF32)20 Method (java.lang.reflect.Method)17 GrayU8 (boofcv.struct.image.GrayU8)15 Bitmap (android.graphics.Bitmap)4 ImageBorder_S32 (boofcv.core.image.border.ImageBorder_S32)4 GrayS16 (boofcv.struct.image.GrayS16)4 GrayS32 (boofcv.struct.image.GrayS32)4 Planar (boofcv.struct.image.Planar)4 InvocationTargetException (java.lang.reflect.InvocationTargetException)4 IntegralKernel (boofcv.alg.transform.ii.IntegralKernel)3 ImageRectangle (boofcv.struct.ImageRectangle)3 FDistort (boofcv.abst.distort.FDistort)2 ImageBorder_F32 (boofcv.core.image.border.ImageBorder_F32)2 FactoryDescribeImageDense (boofcv.factory.feature.dense.FactoryDescribeImageDense)2 Kernel2D_S32 (boofcv.struct.convolve.Kernel2D_S32)2 TupleDesc_F64 (boofcv.struct.feature.TupleDesc_F64)2