use of boofcv.struct.image.GrayU8 in project BoofCV by lessthanoptimal.
the class TestWrapFHtoInterestPoint method standard.
@Test
public void standard() {
WrapFHtoInterestPoint alg = new WrapFHtoInterestPoint(detector);
new GeneralInterestPointDetectorChecks(alg, false, true, GrayU8.class) {
}.performAllTests();
}
use of boofcv.struct.image.GrayU8 in project BoofCV by lessthanoptimal.
the class ColorYuv method ycbcrToRgb_U8.
/**
* Conversion from YCbCr to RGB.
*
* NOTE: Input and output image can be the same instance.
*
* @param yuv YCbCr encoded 8-bit image
* @param rgb RGB encoded 8-bit image
*/
public static void ycbcrToRgb_U8(Planar<GrayU8> yuv, Planar<GrayU8> rgb) {
GrayU8 Y = yuv.getBand(0);
GrayU8 U = yuv.getBand(1);
GrayU8 V = yuv.getBand(2);
GrayU8 R = rgb.getBand(0);
GrayU8 G = rgb.getBand(1);
GrayU8 B = rgb.getBand(2);
for (int row = 0; row < yuv.height; row++) {
int indexYuv = yuv.startIndex + row * yuv.stride;
int indexRgb = rgb.startIndex + row * rgb.stride;
for (int col = 0; col < yuv.width; col++, indexYuv++, indexRgb++) {
int y = 1191 * ((Y.data[indexYuv] & 0xFF) - 16);
int cb = (U.data[indexYuv] & 0xFF) - 128;
int cr = (V.data[indexYuv] & 0xFF) - 128;
if (y < 0)
y = 0;
int r = (y + 1836 * cr) >> 10;
int g = (y - 547 * cr - 218 * cb) >> 10;
int b = (y + 2165 * cb) >> 10;
if (r < 0)
r = 0;
else if (r > 255)
r = 255;
if (g < 0)
g = 0;
else if (g > 255)
g = 255;
if (b < 0)
b = 0;
else if (b > 255)
b = 255;
R.data[indexRgb] = (byte) r;
G.data[indexRgb] = (byte) g;
B.data[indexRgb] = (byte) b;
}
}
}
use of boofcv.struct.image.GrayU8 in project BoofCV by lessthanoptimal.
the class BinaryImageOps method erode4.
/**
* <p>
* Erodes an image according to a 4-neighborhood. Unless a pixel is connected to all its neighbors its value
* is set to zero.
* </p>
*
* @param input Input image. Not modified.
* @param numTimes How many times the operation will be applied to the image.
* @param output If not null, the output image. If null a new image is declared and returned. Modified.
* @return Output image.
*/
public static GrayU8 erode4(GrayU8 input, int numTimes, GrayU8 output) {
output = InputSanityCheck.checkDeclare(input, output);
if (numTimes <= 0)
throw new IllegalArgumentException("numTimes must be >= 1");
ImplBinaryInnerOps.erode4(input, output);
ImplBinaryBorderOps.erode4(input, output);
if (numTimes > 1) {
GrayU8 tmp1 = new GrayU8(input.width, input.height);
GrayU8 tmp2 = output;
for (int i = 1; i < numTimes; i++) {
ImplBinaryInnerOps.erode4(tmp2, tmp1);
ImplBinaryBorderOps.erode4(tmp2, tmp1);
GrayU8 a = tmp1;
tmp1 = tmp2;
tmp2 = a;
}
if (tmp2 != output) {
output.setTo(tmp2);
}
}
return output;
}
use of boofcv.struct.image.GrayU8 in project BoofCV by lessthanoptimal.
the class BinaryImageOps method dilate4.
/**
* <p>
* Dilates an image according to a 4-neighborhood. If a pixel is connected to any other pixel then its output
* value will be one.
* </p>
*
* @param input Input image. Not modified.
* @param numTimes How many times the operation will be applied to the image.
* @param output If not null, the output image. If null a new image is declared and returned. Modified.
* @return Output image.
*/
public static GrayU8 dilate4(GrayU8 input, int numTimes, GrayU8 output) {
output = InputSanityCheck.checkDeclare(input, output);
ImplBinaryInnerOps.dilate4(input, output);
ImplBinaryBorderOps.dilate4(input, output);
if (numTimes > 1) {
GrayU8 tmp1 = new GrayU8(input.width, input.height);
GrayU8 tmp2 = output;
for (int i = 1; i < numTimes; i++) {
ImplBinaryInnerOps.dilate4(tmp2, tmp1);
ImplBinaryBorderOps.dilate4(tmp2, tmp1);
GrayU8 a = tmp1;
tmp1 = tmp2;
tmp2 = a;
}
if (tmp2 != output) {
output.setTo(tmp2);
}
}
return output;
}
use of boofcv.struct.image.GrayU8 in project BoofCV by lessthanoptimal.
the class BinaryImageOps method erode8.
/**
* <p>
* Erodes an image according to a 8-neighborhood. Unless a pixel is connected to all its neighbors its value
* is set to zero.
* </p>
*
* @param input Input image. Not modified.
* @param numTimes How many times the operation will be applied to the image.
* @param output If not null, the output image. If null a new image is declared and returned. Modified.
* @return Output image.
*/
public static GrayU8 erode8(GrayU8 input, int numTimes, GrayU8 output) {
output = InputSanityCheck.checkDeclare(input, output);
ImplBinaryInnerOps.erode8(input, output);
ImplBinaryBorderOps.erode8(input, output);
if (numTimes > 1) {
GrayU8 tmp1 = new GrayU8(input.width, input.height);
GrayU8 tmp2 = output;
for (int i = 1; i < numTimes; i++) {
ImplBinaryInnerOps.erode8(tmp2, tmp1);
ImplBinaryBorderOps.erode8(tmp2, tmp1);
GrayU8 a = tmp1;
tmp1 = tmp2;
tmp2 = a;
}
if (tmp2 != output) {
output.setTo(tmp2);
}
}
return output;
}
Aggregations