use of boofcv.struct.image.GrayF32 in project BoofCV by lessthanoptimal.
the class TestDistortSupport method distortScale.
@Test
public void distortScale() {
GrayF32 a = new GrayF32(25, 30);
GrayF32 b = new GrayF32(15, 25);
PixelTransform2_F32 tran = DistortSupport.transformScale(a, b, null);
// check edge cases at the image border
tran.compute(0, 0);
assertEquals(0, tran.distX, 1e-8);
assertEquals(0, tran.distY, 1e-8);
tran.compute(24, 29);
assertEquals(24 * 15.0 / 25.0, tran.distX, 1e-4);
assertEquals(29 * 25.0 / 30.0, tran.distY, 1e-4);
// some point inside now
tran.compute(5, 6);
assertEquals(5.0 * 15.0 / 25.0, tran.distX, 1e-4);
assertEquals(6.0 * 25.0 / 30.0, tran.distY, 1e-4);
}
use of boofcv.struct.image.GrayF32 in project BoofCV by lessthanoptimal.
the class WrapSiftDetector method detect.
@Override
public void detect(T image) {
GrayF32 input;
if (image instanceof GrayF32) {
input = (GrayF32) image;
} else {
imageFloat.reshape(image.width, image.height);
GConvertImage.convert(image, imageFloat);
input = imageFloat;
}
detector.process(input);
}
use of boofcv.struct.image.GrayF32 in project BoofCV by lessthanoptimal.
the class FhEdgeWeights4_PLF32 method checkAround.
private void checkAround(int x, int y, Planar<GrayF32> input, FastQueue<Edge> edges) {
int indexSrc = input.startIndex + y * input.stride + x;
int indexA = y * input.width + x;
for (int i = 0; i < numBands; i++) {
GrayF32 band = input.getBand(i);
pixelColor[i] = band.data[indexSrc];
}
check(x + 1, y, pixelColor, indexA, input, edges);
check(x, y + 1, pixelColor, indexA, input, edges);
}
use of boofcv.struct.image.GrayF32 in project BoofCV by lessthanoptimal.
the class FhEdgeWeights4_PLF32 method process.
@Override
public void process(Planar<GrayF32> input, FastQueue<Edge> edges) {
edges.reset();
int w = input.width - 1;
int h = input.height - 1;
// First consider the inner pixels
for (int y = 0; y < h; y++) {
int indexSrc = input.startIndex + y * input.stride + 0;
int indexDst = +y * input.width + 0;
for (int x = 0; x < w; x++, indexSrc++, indexDst++) {
float weight1 = 0, weight2 = 0;
for (int i = 0; i < numBands; i++) {
GrayF32 band = input.getBand(i);
// (x,y)
float color0 = band.data[indexSrc];
// (x+1,y)
float color1 = band.data[indexSrc + 1];
// (x,y+1)
float color2 = band.data[indexSrc + input.stride];
float diff1 = color0 - color1;
float diff2 = color0 - color2;
weight1 += diff1 * diff1;
weight2 += diff2 * diff2;
}
Edge e1 = edges.grow();
Edge e2 = edges.grow();
e1.sortValue = (float) Math.sqrt(weight1);
e1.indexA = indexDst;
e1.indexB = indexDst + 1;
e2.sortValue = (float) Math.sqrt(weight2);
e2.indexA = indexDst;
e2.indexB = indexDst + input.width;
}
}
// Handle border pixels
for (int y = 0; y < h; y++) {
checkAround(w, y, input, edges);
}
for (int x = 0; x < w; x++) {
checkAround(x, h, input, edges);
}
}
use of boofcv.struct.image.GrayF32 in project BoofCV by lessthanoptimal.
the class FhEdgeWeights8_PLF32 method checkAround.
private void checkAround(int x, int y, Planar<GrayF32> input, FastQueue<Edge> edges) {
int indexSrc = input.startIndex + y * input.stride + x;
int indexA = y * input.width + x;
for (int i = 0; i < numBands; i++) {
GrayF32 band = input.getBand(i);
pixelColor[i] = band.data[indexSrc];
}
check(x + 1, y, pixelColor, indexA, input, edges);
check(x, y + 1, pixelColor, indexA, input, edges);
check(x + 1, y + 1, pixelColor, indexA, input, edges);
check(x - 1, y + 1, pixelColor, indexA, input, edges);
}
Aggregations