use of boofcv.struct.image.GrayS16 in project BoofCV by lessthanoptimal.
the class TestCannyEdgeDynamic method canHandleNoTexture.
/**
* Test the pathological case where the input image has no texture. The threshold will be zero and the
* edge intensity will be zero everywhere.
*/
@Test
public void canHandleNoTexture() {
GrayU8 input = new GrayU8(width, height);
GrayU8 output = new GrayU8(width, height);
ImageMiscOps.fill(output, 2);
CannyEdge<GrayU8, GrayS16> alg = FactoryEdgeDetectors.canny(2, false, true, GrayU8.class, GrayS16.class);
alg.process(input, 0.075f, 0.3f, output);
for (int i = 0; i < output.data.length; i++) {
assertEquals(0, output.data[i]);
}
// try it with a trace now
alg = FactoryEdgeDetectors.canny(2, true, true, GrayU8.class, GrayS16.class);
ImageMiscOps.fill(output, 2);
alg.process(input, 0.075f, 0.3f, output);
List<EdgeContour> contour = alg.getContours();
assertTrue(contour.size() == 0);
for (int i = 0; i < output.data.length; i++) assertEquals(0, output.data[i]);
}
use of boofcv.struct.image.GrayS16 in project BoofCV by lessthanoptimal.
the class TestCannyEdgeDynamic method basicTestPoints.
/**
* Just checks to see if it computes a reasonable threshold given fractional parameters
*/
@Test
public void basicTestPoints() {
GrayU8 input = new GrayU8(width, height);
ImageMiscOps.fillRectangle(input, 50, 20, 30, 40, 50);
BlurFilter<GrayU8> blur = FactoryBlurFilter.gaussian(ImageType.single(GrayU8.class), -1, 1);
ImageGradient<GrayU8, GrayS16> gradient = FactoryDerivative.sobel(GrayU8.class, GrayS16.class);
CannyEdgeDynamic<GrayU8, GrayS16> alg = new CannyEdgeDynamic<>(blur, gradient, true);
alg.process(input, 0.2f, 0.4f, null);
List<EdgeContour> contour = alg.getContours();
int totalPass = 0;
for (EdgeContour e : contour) {
int total = 0;
for (EdgeSegment s : e.segments) {
// really should check to see if the points are near the rectangle....
total += s.points.size();
}
if (total >= 2 * 50 + 2 * 38)
totalPass++;
}
assertEquals(1, totalPass);
}
use of boofcv.struct.image.GrayS16 in project BoofCV by lessthanoptimal.
the class BenchmarkSsdCornerIntensity method main.
public static void main(String[] args) {
derivX_F32 = new GrayF32(imgWidth, imgHeight);
derivY_F32 = new GrayF32(imgWidth, imgHeight);
derivXX_F32 = new GrayF32(imgWidth, imgHeight);
derivYY_F32 = new GrayF32(imgWidth, imgHeight);
derivXY_F32 = new GrayF32(imgWidth, imgHeight);
derivX_I16 = new GrayS16(imgWidth, imgHeight);
derivY_I16 = new GrayS16(imgWidth, imgHeight);
derivXX_I16 = new GrayS16(imgWidth, imgHeight);
derivYY_I16 = new GrayS16(imgWidth, imgHeight);
derivXY_I16 = new GrayS16(imgWidth, imgHeight);
ImageMiscOps.fillUniform(derivX_F32, rand, 0, 255);
ImageMiscOps.fillUniform(derivY_F32, rand, 0, 255);
ImageMiscOps.fillUniform(derivXX_F32, rand, 0, 255);
ImageMiscOps.fillUniform(derivYY_F32, rand, 0, 255);
ImageMiscOps.fillUniform(derivXY_F32, rand, 0, 255);
ImageMiscOps.fillUniform(derivX_I16, rand, 0, 255);
ImageMiscOps.fillUniform(derivY_I16, rand, 0, 255);
ImageMiscOps.fillUniform(derivXX_I16, rand, 0, 255);
ImageMiscOps.fillUniform(derivYY_I16, rand, 0, 255);
ImageMiscOps.fillUniform(derivXY_I16, rand, 0, 255);
System.out.println("========= Profile Image Size " + imgWidth + " x " + imgHeight + " ==========");
System.out.println();
ProfileOperation.printOpsPerSec(new KLT_F32(), TEST_TIME);
ProfileOperation.printOpsPerSec(new KLT_WEIGHT_F32(), TEST_TIME);
ProfileOperation.printOpsPerSec(new Harris_F32(), TEST_TIME);
ProfileOperation.printOpsPerSec(new KitRos_F32(), TEST_TIME);
ProfileOperation.printOpsPerSec(new KLT_I16(), TEST_TIME);
ProfileOperation.printOpsPerSec(new KLT_WEIGHT_I16(), TEST_TIME);
ProfileOperation.printOpsPerSec(new Harris_I16(), TEST_TIME);
ProfileOperation.printOpsPerSec(new KitRos_I16(), TEST_TIME);
ProfileOperation.printOpsPerSec(new KLT_Naive_I16(), TEST_TIME);
}
use of boofcv.struct.image.GrayS16 in project BoofCV by lessthanoptimal.
the class BenchmarkDerivativeBase method process.
public void process() {
imgInt8 = new GrayU8(imgWidth, imgHeight);
derivX_I16 = new GrayS16(imgWidth, imgHeight);
derivY_I16 = new GrayS16(imgWidth, imgHeight);
derivXY_I16 = new GrayS16(imgWidth, imgHeight);
imgFloat32 = new GrayF32(imgWidth, imgHeight);
derivX_F32 = new GrayF32(imgWidth, imgHeight);
derivY_F32 = new GrayF32(imgWidth, imgHeight);
derivXY_F32 = new GrayF32(imgWidth, imgHeight);
Random rand = new Random(123);
GImageMiscOps.fillUniform(imgInt8, rand, 0, 100);
GImageMiscOps.fillUniform(imgFloat32, rand, 0, 100);
System.out.println("========= Profile Image Size " + imgWidth + " x " + imgHeight + " ==========");
System.out.println(" border = " + border);
System.out.println();
System.out.println(" GrayU8");
System.out.println();
profile_I8();
System.out.println("\n GrayF32");
System.out.println();
profile_F32();
}
use of boofcv.struct.image.GrayS16 in project BoofCV by lessthanoptimal.
the class TestFactoryDerivativeSparse method laplacian_I.
@Test
public void laplacian_I() {
GrayU8 input = new GrayU8(width, height);
GrayS16 expected = new GrayS16(width, height);
GImageMiscOps.fillUniform(input, rand, 0, 20);
LaplacianEdge.process(input, expected);
ImageFunctionSparse<GrayU8> func = FactoryDerivativeSparse.createLaplacian(GrayU8.class, null);
func.setImage(input);
double found = func.compute(6, 8);
assertEquals(expected.get(6, 8), found, 1e-4);
}
Aggregations