use of boofcv.core.image.border.ImageBorder_F32 in project BoofCV by lessthanoptimal.
the class TestImplEnhanceFilter method sharpenBorder4.
public void sharpenBorder4(ImageGray input, ImageGray output) {
ImageGray expected;
GImageMiscOps.fillUniform(input, rand, 0, 10);
if (input.getDataType().isInteger()) {
BoofTesting.callStaticMethod(ImplEnhanceFilter.class, "sharpenBorder4", input, output, 0, 255);
expected = new GrayS16(input.width, input.height);
ImageBorder_S32 border = BoofDefaults.borderDerivative_I32();
border.setImage(input);
ConvolveJustBorder_General_SB.convolve(ImplEnhanceFilter.kernelEnhance4_I32, border, (GrayS16) expected);
GPixelMath.boundImage(expected, 0, 255);
} else {
BoofTesting.callStaticMethod(ImplEnhanceFilter.class, "sharpenBorder4", input, output, 0f, 255f);
expected = new GrayF32(input.width, input.height);
ImageBorder_F32 border = BoofDefaults.borderDerivative_F32();
border.setImage((GrayF32) input);
ConvolveJustBorder_General_SB.convolve(ImplEnhanceFilter.kernelEnhance4_F32, border, (GrayF32) expected);
GPixelMath.boundImage(expected, 0, 255);
}
BoofTesting.assertEquals(expected, output, 1e-5);
}
use of boofcv.core.image.border.ImageBorder_F32 in project BoofCV by lessthanoptimal.
the class TestImplEnhanceFilter method sharpenBorder8.
public void sharpenBorder8(ImageGray input, ImageGray output) {
ImageGray expected;
GImageMiscOps.fillUniform(input, rand, 0, 10);
if (input.getDataType().isInteger()) {
BoofTesting.callStaticMethod(ImplEnhanceFilter.class, "sharpenBorder8", input, output, 0, 255);
expected = new GrayS16(input.width, input.height);
ImageBorder_S32 border = BoofDefaults.borderDerivative_I32();
border.setImage(input);
ConvolveJustBorder_General_SB.convolve(ImplEnhanceFilter.kernelEnhance8_I32, border, (GrayS16) expected);
GPixelMath.boundImage(expected, 0, 255);
} else {
BoofTesting.callStaticMethod(ImplEnhanceFilter.class, "sharpenBorder8", input, output, 0f, 255f);
expected = new GrayF32(input.width, input.height);
ImageBorder_F32 border = BoofDefaults.borderDerivative_F32();
border.setImage((GrayF32) input);
ConvolveJustBorder_General_SB.convolve(ImplEnhanceFilter.kernelEnhance8_F32, border, (GrayF32) expected);
GPixelMath.boundImage(expected, 0, 255);
}
BoofTesting.assertEquals(expected, output, 1e-5);
}
use of boofcv.core.image.border.ImageBorder_F32 in project BoofCV by lessthanoptimal.
the class ImplPolynomialPixel_F32 method get_border.
public float get_border(float x, float y) {
int xt = (int) Math.floor(x);
int yt = (int) Math.floor(y);
int x0 = xt - M / 2 + offM;
int y0 = yt - M / 2 + offM;
ImageBorder_F32 border = (ImageBorder_F32) this.border;
interp1D.setInput(horiz, horiz.length);
for (int i = 0; i < M; i++) {
for (int j = 0; j < M; j++) {
horiz[j] = border.get(j + x0, i + y0);
}
vert[i] = interp1D.process(x - x0, 0, M - 1);
}
interp1D.setInput(vert, vert.length);
float ret = interp1D.process(y - y0, 0, M - 1);
// because it is fitting polynomials it can go above or below max or min values.
if (ret > max) {
ret = max;
} else if (ret < min) {
ret = min;
}
return ret;
}
use of boofcv.core.image.border.ImageBorder_F32 in project BoofCV by lessthanoptimal.
the class TestDerivativeIntegralImage method kernelDerivXX.
@Test
public void kernelDerivXX() {
GrayF32 orig = new GrayF32(width, height);
GrayF32 integral = new GrayF32(width, height);
ImageMiscOps.fillUniform(orig, rand, 0, 20);
GrayF32 expected = new GrayF32(width, height);
GrayF32 found = new GrayF32(width, height);
IntegralImageOps.transform(orig, integral);
ImageBorder_F32 border = (ImageBorder_F32) FactoryImageBorderAlgs.value(orig, 0);
for (int i = 1; i <= 5; i += 2) {
int size = i * 3;
IntegralKernel kernelI = DerivativeIntegralImage.kernelDerivXX(size, null);
Kernel2D_F32 kernel = createDerivXX(size);
ConvolveImage.convolve(kernel, orig, expected, border);
IntegralImageOps.convolve(integral, kernelI, found);
BoofTesting.assertEquals(expected, found, 1e-2);
}
}
use of boofcv.core.image.border.ImageBorder_F32 in project BoofCV by lessthanoptimal.
the class TestGradientTwo0 method compareToConvolve_F32.
@Test
public void compareToConvolve_F32() throws NoSuchMethodException {
CompareDerivativeToConvolution validator = new CompareDerivativeToConvolution();
validator.setTarget(GradientTwo0.class.getMethod("process", GrayF32.class, GrayF32.class, GrayF32.class, ImageBorder_F32.class));
validator.setKernel(0, GradientTwo0.kernelDeriv_F32, true);
validator.setKernel(1, GradientTwo0.kernelDeriv_F32, false);
GrayF32 input = new GrayF32(width, height);
ImageMiscOps.fillUniform(input, rand, 0, 10);
GrayF32 derivX = new GrayF32(width, height);
GrayF32 derivY = new GrayF32(width, height);
validator.compare(input, derivX, derivY);
}
Aggregations