use of boofcv.struct.image.ImageGray in project BoofCV by lessthanoptimal.
the class TestThresholdImageOps method localGaussian.
@Test
public void localGaussian() {
int total = 0;
Method[] list = ThresholdImageOps.class.getMethods();
for (Method m : list) {
if (!m.getName().equals("localGaussian"))
continue;
Class[] param = m.getParameterTypes();
ImageGray input = GeneralizedImageOps.createSingleBand(param[0], width, height);
GrayU8 output = new GrayU8(width, height);
GImageMiscOps.fillUniform(input, rand, 0, 200);
BoofTesting.checkSubImage(this, "performLocalGaussian", true, m, input, output);
total++;
}
assertEquals(2, total);
}
use of boofcv.struct.image.ImageGray in project BoofCV by lessthanoptimal.
the class TestThresholdImageOps method naiveLocalSquare.
public void naiveLocalSquare(ImageGray input, GrayU8 output, int radius, double scale, boolean down) {
ImageGray blur;
boolean isInt;
if (input instanceof GrayU8) {
isInt = true;
blur = BlurImageOps.mean((GrayU8) input, null, radius, null);
} else {
isInt = false;
blur = BlurImageOps.mean((GrayF32) input, null, radius, null);
}
float fscale = (float) scale;
for (int y = 0; y < input.height; y++) {
for (int x = 0; x < input.width; x++) {
double threshold = GeneralizedImageOps.get(blur, x, y);
double v = GeneralizedImageOps.get(input, x, y);
boolean one;
if (down) {
if (isInt) {
one = (int) v <= ((int) threshold) * fscale;
} else {
one = v <= threshold * fscale;
}
} else {
if (isInt) {
one = ((int) v) * fscale > (int) threshold;
} else {
one = v * fscale > threshold;
}
}
if (one) {
output.set(x, y, 1);
} else {
output.set(x, y, 0);
}
}
}
}
use of boofcv.struct.image.ImageGray in project BoofCV by lessthanoptimal.
the class TestThresholdImageOps method threshold.
@Test
public void threshold() {
int total = 0;
Method[] list = ThresholdImageOps.class.getMethods();
for (Method m : list) {
if (!m.getName().equals("threshold"))
continue;
Class[] param = m.getParameterTypes();
ImageGray input = GeneralizedImageOps.createSingleBand(param[0], width, height);
GrayU8 output = new GrayU8(width, height);
GImageGray a = FactoryGImageGray.wrap(input);
for (int y = 0; y < input.height; y++) {
for (int x = 0; x < input.width; x++) {
a.set(x, y, x);
}
}
BoofTesting.checkSubImage(this, "performThreshold", true, m, input, output);
total++;
}
assertEquals(6, total);
}
use of boofcv.struct.image.ImageGray in project BoofCV by lessthanoptimal.
the class TestImplMedianSortEdgeNaive 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);
Object[][] ret = new Object[1][c.length];
ret[0][0] = input;
ret[0][1] = output;
ret[0][2] = radius;
ret[0][3] = null;
return ret;
}
use of boofcv.struct.image.ImageGray in project BoofCV by lessthanoptimal.
the class TestImplMedianSortNaive method trivialTest.
@Test
public void trivialTest() {
GrayU8 templateImage = new GrayU8(4, 4);
for (int i = 0; i < templateImage.width; i++) {
for (int j = 0; j < templateImage.height; j++) {
templateImage.set(j, i, i * templateImage.width + j);
}
}
int numFound = 0;
Method[] methods = ImplMedianSortNaive.class.getMethods();
for (Method m : methods) {
if (!m.getName().equals("process"))
continue;
if (m.getParameterTypes().length != 4)
continue;
Class[] params = m.getParameterTypes();
ImageGray input = GeneralizedImageOps.createSingleBand(params[0], 4, 4);
ImageGray found = GeneralizedImageOps.createSingleBand(params[1], 4, 4);
GConvertImage.convert(templateImage, input);
BoofTesting.checkSubImage(this, "trivialTest", true, m, input, found);
numFound++;
}
assertEquals(2, numFound);
}
Aggregations