void Binarization::ExtractBoundary(unsigned char *buffer_in, unsigned char *buffer_out, bool inverse) {
	TEST_OVERLAP(ExtractBoundary(buffer_in, buffer_out, inverse));

	Erode(buffer_in, buffer_out, inverse);

	for(int i = 1; i < height_ - 1; i++)
		for(int j = 1; j < width_ - 1; j++) {
			buffer_out[(i * width_ + j) * 3 + 2] = (buffer_out[(i * width_ + j) * 3 + 2] ^ buffer_in[(i * width_ + j) * 3 + 2]) ? 255 : 0;
			buffer_out[(i * width_ + j) * 3 + 1] = (buffer_out[(i * width_ + j) * 3 + 1] ^ buffer_in[(i * width_ + j) * 3 + 1]) ? 255 : 0;
			buffer_out[(i * width_ + j) * 3 + 0] = (buffer_out[(i * width_ + j) * 3 + 0] ^ buffer_in[(i * width_ + j) * 3 + 0]) ? 255 : 0;
		}
}
void Binarization::Erode(unsigned char *buffer_in, unsigned char *buffer_out, bool inverse) {
	TEST_OVERLAP(Erode(buffer_in, buffer_out, inverse));

	for(int i = 1; i < height_ - 1; i++)
		for(int j = 1; j < width_ - 1; j++)
			if(SatisfyErosion(buffer_in, i, j, inverse)) {
				buffer_out[(i * width_ + j) * 3 + 2] = inverse ? 0 : 255;
				buffer_out[(i * width_ + j) * 3 + 1] = inverse ? 0 : 255;
				buffer_out[(i * width_ + j) * 3 + 0] = inverse ? 0 : 255;
			} else {
				buffer_out[(i * width_ + j) * 3 + 2] = inverse ? 255 : 0;
				buffer_out[(i * width_ + j) * 3 + 1] = inverse ? 255 : 0;
				buffer_out[(i * width_ + j) * 3 + 0] = inverse ? 255 : 0;
			}
}
Beispiel #3
0
bool IntersectionTests::boxAndBox(
    const CollisionBox &one,
    const CollisionBox &two
    )
{
    // Find the vector between the two centres
    Vector3 toCentre = two.getAxis(3) - one.getAxis(3);

    return (
        // Check on box one's axes first
        TEST_OVERLAP(one.getAxis(0)) &&
        TEST_OVERLAP(one.getAxis(1)) &&
        TEST_OVERLAP(one.getAxis(2)) &&

        // And on two's
        TEST_OVERLAP(two.getAxis(0)) &&
        TEST_OVERLAP(two.getAxis(1)) &&
        TEST_OVERLAP(two.getAxis(2)) &&

        // Now on the cross products
        TEST_OVERLAP(one.getAxis(0) % two.getAxis(0)) &&
        TEST_OVERLAP(one.getAxis(0) % two.getAxis(1)) &&
        TEST_OVERLAP(one.getAxis(0) % two.getAxis(2)) &&
        TEST_OVERLAP(one.getAxis(1) % two.getAxis(0)) &&
        TEST_OVERLAP(one.getAxis(1) % two.getAxis(1)) &&
        TEST_OVERLAP(one.getAxis(1) % two.getAxis(2)) &&
        TEST_OVERLAP(one.getAxis(2) % two.getAxis(0)) &&
        TEST_OVERLAP(one.getAxis(2) % two.getAxis(1)) &&
        TEST_OVERLAP(one.getAxis(2) % two.getAxis(2))
    );
}