use of boofcv.struct.image.GrayS32 in project BoofCV by lessthanoptimal.
the class TestImplSurfDescribeOps method gradientInner_I32.
@Test
public void gradientInner_I32() {
GrayS32 ii = new GrayS32(width, height);
GImageMiscOps.fillUniform(ii, rand, 0, 99);
int r = 2;
int w = r * 2 + 1;
double[] expectedX = new double[w * w];
double[] expectedY = new double[w * w];
int[] foundX = new int[w * w];
int[] foundY = new int[w * w];
for (double scale = 0.2; scale <= 1.8; scale += 0.2) {
ImplSurfDescribeOps.naiveGradient(ii, 10, 9, scale, w, 4 * scale, false, expectedX, expectedY);
ImplSurfDescribeOps.gradientInner(ii, 10, 9, scale, w, 4 * scale, foundX, foundY);
for (int i = 0; i < foundX.length; i++) {
assertEquals("at " + i, expectedX[i], foundX[i], 1e-4);
assertEquals("at " + i, expectedY[i], foundY[i], 1e-4);
}
for (int i = 0; i < foundX.length; i++) {
assertTrue(foundX[i] != 0);
assertTrue(foundY[i] != 0);
}
}
}
use of boofcv.struct.image.GrayS32 in project BoofCV by lessthanoptimal.
the class GeneralImageSuperpixelsChecks method sequentialNumbers.
/**
* Makes sure that there really are regions 0 N-1 in the output image
*/
@Test
public void sequentialNumbers() {
for (ImageType<T> t : imageTypes) {
ImageSuperpixels<T> alg = createAlg(t);
T input = t.createImage(width, height);
GrayS32 output = new GrayS32(width, height);
GImageMiscOps.fillUniform(input, rand, 0, 100);
alg.segment(input, output);
int N = alg.getTotalSuperpixels();
assertTrue(N > 2);
boolean[] found = new boolean[N];
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
found[output.get(x, y)] = true;
}
}
for (int i = 0; i < N; i++) {
assertTrue(found[i]);
}
}
}
use of boofcv.struct.image.GrayS32 in project BoofCV by lessthanoptimal.
the class GeneralImageSuperpixelsChecks method multipleCalls.
/**
* /**
* Produces the same results when run multiple times
*/
@Test
public void multipleCalls() {
for (ImageType<T> t : imageTypes) {
ImageSuperpixels<T> alg = createAlg(t);
T input = t.createImage(width, height);
GrayS32 output = new GrayS32(width, height);
GImageMiscOps.fillUniform(input, rand, 0, 100);
alg.segment(input, output);
GrayS32 output2 = new GrayS32(width, height);
alg.segment(input, output2);
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
assertEquals(output.get(x, y), output2.get(x, y));
}
}
}
}
use of boofcv.struct.image.GrayS32 in project BoofCV by lessthanoptimal.
the class GeneralImageSuperpixelsChecks method connectivity.
/**
* Makes sure all pixels with the same label are connected
*/
@Test
public void connectivity() {
for (ImageType<T> t : imageTypes) {
// System.out.println("Image type "+t);
ImageSuperpixels<T> alg = createAlg(t);
T input = t.createImage(width, height);
GrayS32 output = new GrayS32(width, height);
GImageMiscOps.fillUniform(input, rand, 0, 100);
alg.segment(input, output);
assertTrue(alg.getTotalSuperpixels() > 4);
GrayU8 binary = new GrayU8(width, height);
boolean[] selected = new boolean[alg.getTotalSuperpixels()];
for (int i = 0; i < alg.getTotalSuperpixels(); i++) {
selected[i] = true;
BinaryImageOps.labelToBinary(output, binary, selected);
selected[i] = false;
// the number of blobs should always be one
ConnectRule rule = alg.getRule();
assertEquals(1, BinaryImageOps.contour(binary, rule, null).size());
}
}
}
use of boofcv.struct.image.GrayS32 in project BoofCV by lessthanoptimal.
the class GeneralImageSuperpixelsChecks method changeInImageSize.
/**
* See if it won't blow up if input image size is changed
*/
@Test
public void changeInImageSize() {
for (ImageType<T> t : imageTypes) {
ImageSuperpixels<T> alg = createAlg(t);
T input = t.createImage(width / 2, height / 2);
GrayS32 output = new GrayS32(width / 2, height / 2);
GImageMiscOps.fillUniform(input, rand, 0, 100);
alg.segment(input, output);
input = t.createImage(width, height);
output = new GrayS32(width, height);
alg.segment(input, output);
}
}
Aggregations