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;
}
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);
}
}
}
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");
}
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);
}
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);
}
Aggregations