use of boofcv.core.image.border.ImageBorder_S32 in project BoofCV by lessthanoptimal.
the class ImplBinaryBorderOps method edge8.
public static void edge8(GrayU8 input, GrayU8 output) {
ImageBorder_S32 in = ImageBorderValue.wrap(input, 1);
final int h = input.height - 1;
final int w = input.width - 1;
for (int x = 0; x < input.width; x++) {
// check top edge
if ((in.get(x - 1, 0) + in.get(x + 1, 0) + in.get(x - 1, 1) + in.get(x, 1) + in.get(x + 1, 1)) == 5)
output.set(x, 0, 0);
else
output.set(x, 0, input.get(x, 0));
// check bottom edge
if ((in.get(x - 1, h) + in.get(x + 1, h) + in.get(x - 1, h - 1) + in.get(x, h - 1) + in.get(x + 1, h - 1)) == 5)
output.set(x, h, 0);
else
output.set(x, h, input.get(x, h));
}
for (int y = 0; y < input.height; y++) {
// check left edge
if ((in.get(1, y) + in.get(0, y - 1) + in.get(1, y - 1) + in.get(0, y + 1) + in.get(1, y + 1)) == 5)
output.set(0, y, 0);
else
output.set(0, y, input.get(0, y));
// check right edge
if ((in.get(w - 1, y) + in.get(w - 1, y - 1) + in.get(w, y - 1) + in.get(w - 1, y + 1) + in.get(w, y + 1)) == 5)
output.set(w, y, 0);
else
output.set(w, y, input.get(w, y));
}
}
use of boofcv.core.image.border.ImageBorder_S32 in project BoofCV by lessthanoptimal.
the class ImplBinaryBorderOps method erode8.
public static void erode8(GrayU8 input, GrayU8 output) {
ImageBorder_S32 in = ImageBorderValue.wrap(input, 1);
final int h = input.height - 1;
final int w = input.width - 1;
for (int x = 0; x < input.width; x++) {
// check top edge
if ((in.get(x, 0) + in.get(x - 1, 0) + in.get(x + 1, 0) + in.get(x - 1, 1) + in.get(x, 1) + in.get(x + 1, 1)) == 6)
output.set(x, 0, 1);
else
output.set(x, 0, 0);
// check bottom edge
if ((in.get(x, h) + in.get(x - 1, h) + in.get(x + 1, h) + in.get(x - 1, h - 1) + in.get(x, h - 1) + in.get(x + 1, h - 1)) == 6)
output.set(x, h, 1);
else
output.set(x, h, 0);
}
for (int y = 0; y < input.height; y++) {
// check left edge
if ((in.get(0, y) + in.get(1, y) + in.get(0, y - 1) + in.get(1, y - 1) + in.get(0, y + 1) + in.get(1, y + 1)) == 6)
output.set(0, y, 1);
else
output.set(0, y, 0);
// check right edge
if ((in.get(w - 1, y) + in.get(w, y) + in.get(w - 1, y - 1) + in.get(w, y - 1) + in.get(w - 1, y + 1) + in.get(w, y + 1)) == 6)
output.set(w, y, 1);
else
output.set(w, y, 0);
}
}
use of boofcv.core.image.border.ImageBorder_S32 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_S32 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_S32 in project BoofCV by lessthanoptimal.
the class ImplBilinearPixel_S32 method get_border.
public float get_border(float x, float y) {
float xf = (float) Math.floor(x);
float yf = (float) Math.floor(y);
int xt = (int) xf;
int yt = (int) yf;
float ax = x - xf;
float ay = y - yf;
ImageBorder_S32 border = (ImageBorder_S32) this.border;
// (x,y)
float val = (1.0f - ax) * (1.0f - ay) * border.get(xt, yt);
// (x+1,y)
val += ax * (1.0f - ay) * border.get(xt + 1, yt);
// (x+1,y)
;
// (x+1,y+1)
val += ax * ay * border.get(xt + 1, yt + 1);
// (x+1,y+1)
;
// (x,y+1)
val += (1.0f - ax) * ay * border.get(xt, yt + 1);
// (x,y+1)
;
return val;
}
Aggregations