Esempio n. 1
0
	bool DifferenceSumsMaskedAutoTest(int width, int height, const FuncM & f1, const FuncM & f2, int count)
	{
		bool result = true;

		std::cout << "Test " << f1.description << " & " << f2.description << " [" << width << ", " << height << "]." << std::endl;

		View a(width, height, View::Gray8, NULL, TEST_ALIGN(width));
		FillRandom(a);

		View b(width, height, View::Gray8, NULL, TEST_ALIGN(width));
		FillRandom(b);

		View m(width, height, View::Gray8, NULL, TEST_ALIGN(width));
		 uint8_t index = Random(256);
		FillRandomMask(m, index);

        Sums64 s1(count, 0), s2(count, 0);

        TEST_EXECUTE_AT_LEAST_MIN_TIME(f1.Call(a, b, m, index, s1.data()));

        TEST_EXECUTE_AT_LEAST_MIN_TIME(f2.Call(a, b, m, index, s2.data()));

        result = Compare(s1, s2, 0, true, count);

		return result;
	}
Esempio n. 2
0
    bool SegmentationPropagate2x2DataTest(bool create, int width, int height, const FuncP & f)
    {
        bool result = true;

        Data data(f.description);

        TEST_LOG_SS(Info, (create ? "Create" : "Verify") << " test " << f.description << " [" << width << ", " << height << "].");

        const uint8_t currentIndex = 3, invalidIndex = 2, emptyIndex = 0, differenceThreshold = 128;
        View parent(width, height, View::Gray8, NULL, TEST_ALIGN(width));
        View childSrc(2*width, 2*height, View::Gray8, NULL, TEST_ALIGN(width));
        View difference(2*width, 2*height, View::Gray8, NULL, TEST_ALIGN(width));
        View childDst1(2*width, 2*height, View::Gray8, NULL, TEST_ALIGN(width));
        View childDst2(2*width, 2*height, View::Gray8, NULL, TEST_ALIGN(width));

        const uint8_t oldIndex = 3, newIndex = 2;

        if(create)
        {
            FillRandomMask(parent, currentIndex);
            FillRandom(childSrc, 0, currentIndex - 1);
            FillRandom(difference, 255);

            TEST_SAVE(parent);
            TEST_SAVE(childSrc);
            TEST_SAVE(difference);

            f.Call(parent, childSrc, childDst1, difference, currentIndex, invalidIndex, emptyIndex, differenceThreshold);

            TEST_SAVE(childDst1);
        }
        else
        {
            TEST_LOAD(parent);
            TEST_LOAD(childSrc);
            TEST_LOAD(difference);

            TEST_LOAD(childDst1);

            f.Call(parent, childSrc, childDst2, difference, currentIndex, invalidIndex, emptyIndex, differenceThreshold);

            TEST_SAVE(childDst2);

            result = result && Compare(childDst1, childDst2, 0, true, 64);
        }

        return result;
    }
Esempio n. 3
0
    bool DifferenceSumsMaskedDataTest(bool create, int width, int height, const FuncM & f, int count)
    {
        bool result = true;

        Data data(f.description);

        std::cout << (create ? "Create" : "Verify") << " test " << f.description << " [" << width << ", " << height << "]." << std::endl;

        View a(width, height, View::Gray8, NULL, TEST_ALIGN(width));
        View b(width, height, View::Gray8, NULL, TEST_ALIGN(width));
        View m(width, height, View::Gray8, NULL, TEST_ALIGN(width));

        Sums64 s1(count, 0), s2(count, 0);

        uint8_t index = 17;

        if(create)
        {
            FillRandom(a);
            FillRandom(b);
            FillRandomMask(m, index);

            TEST_SAVE(a);
            TEST_SAVE(b);
            TEST_SAVE(m);

            f.Call(a, b, m, index, s1.data());

            TEST_SAVE(s1);
        }
        else
        {
            TEST_LOAD(a);
            TEST_LOAD(b);
            TEST_LOAD(m);

            TEST_LOAD(s1);

            f.Call(a, b, m, index, s2.data());

            TEST_SAVE(s2);

            result = result && Compare(s1, s2, 0, true, count);
        }

        return result;
    }
Esempio n. 4
0
    bool HistogramMaskedDataTest(bool create, int width, int height, const FuncHM & f)
    {
        bool result = true;

        Data data(f.description);

        std::cout << (create ? "Create" : "Verify") << " test " << f.description << " [" << width << ", " << height << "]." << std::endl;

        View src(width, height, View::Gray8, NULL, TEST_ALIGN(width));
        View mask(width, height, View::Gray8, NULL, TEST_ALIGN(width));

        const uint8_t index = 77;
        Histogram h1, h2;

        if(create)
        {
            FillRandom(src);
            FillRandomMask(mask, index);

            TEST_SAVE(src);
            TEST_SAVE(mask);

            f.Call(src, mask, index, h1);

            TEST_SAVE(h1);
        }
        else
        {
            TEST_LOAD(src);
            TEST_LOAD(mask);

            TEST_LOAD(h1);

            f.Call(src, mask, index, h2);

            TEST_SAVE(h2);

            result = result && Compare(h1, h2, 0, true, 32);
        }

        return result;
    }
Esempio n. 5
0
    bool SegmentationChangeIndexAutoTest(int width, int height, const FuncCI & f1, const FuncCI & f2)
    {
        bool result = true;

        TEST_LOG_SS(Info, "Test " << f1.description << " & " << f2.description << " for size [" << width << "," << height << "].");

        const uint8_t oldIndex = 3, newIndex = 2;
        View s(width, height, View::Gray8, NULL, TEST_ALIGN(width));
        View d1(width, height, View::Gray8, NULL, TEST_ALIGN(width));
        View d2(width, height, View::Gray8, NULL, TEST_ALIGN(width));
        FillRandomMask(s, oldIndex);

        TEST_EXECUTE_AT_LEAST_MIN_TIME(f1.Call(s, oldIndex, newIndex, d1));

        TEST_EXECUTE_AT_LEAST_MIN_TIME(f2.Call(s, oldIndex, newIndex, d2));

        result = result && Compare(d1, d2, 0, true, 64);

        return result;
    }
Esempio n. 6
0
    bool SegmentationChangeIndexDataTest(bool create, int width, int height, const FuncCI & f)
    {
        bool result = true;

        Data data(f.description);

        TEST_LOG_SS(Info, (create ? "Create" : "Verify") << " test " << f.description << " [" << width << ", " << height << "].");

        View s(width, height, View::Gray8, NULL, TEST_ALIGN(width));

        View d1(width, height, View::Gray8, NULL, TEST_ALIGN(width));
        View d2(width, height, View::Gray8, NULL, TEST_ALIGN(width));

        const uint8_t oldIndex = 3, newIndex = 2;

        if(create)
        {
            FillRandomMask(s, oldIndex);

            TEST_SAVE(s);

            f.Call(s, oldIndex, newIndex, d1);

            TEST_SAVE(d1);
        }
        else
        {
            TEST_LOAD(s);

            TEST_LOAD(d1);

            f.Call(s, oldIndex, newIndex, d2);

            TEST_SAVE(d2);

            result = result && Compare(d1, d2, 0, true, 64);
        }

        return result;
    }
Esempio n. 7
0
    bool HistogramMaskedAutoTest(int width, int height, const FuncHM & f1, const FuncHM & f2)
    {
        bool result = true;

        std::cout << "Test " << f1.description << " & " << f2.description << " [" << width << ", " << height << "]." << std::endl;

        View s(int(width), int(height), View::Gray8, NULL, TEST_ALIGN(width));
        View m(int(width), int(height), View::Gray8, NULL, TEST_ALIGN(width));

        const uint8_t index = 77;
        FillRandom(s);
        FillRandomMask(m, index);

        Histogram h1 = {0}, h2 = {0};

        TEST_EXECUTE_AT_LEAST_MIN_TIME(f1.Call(s, m, index, h1));

        TEST_EXECUTE_AT_LEAST_MIN_TIME(f2.Call(s, m, index, h2));

        result = result && Compare(h1, h2, 0, true, 32);

        return result;
    }
Esempio n. 8
0
    bool SegmentationPropagate2x2AutoTest(int width, int height, const FuncP & f1, const FuncP & f2)
    {
        bool result = true;

        TEST_LOG_SS(Info, "Test " << f1.description << " & " << f2.description << " for size [" << width << "," << height << "].");

        const uint8_t currentIndex = 3, invalidIndex = 2, emptyIndex = 0, differenceThreshold = 128;
        View parent(width, height, View::Gray8, NULL, TEST_ALIGN(width));
        View childSrc(2*width, 2*height, View::Gray8, NULL, TEST_ALIGN(width));
        View difference(2*width, 2*height, View::Gray8, NULL, TEST_ALIGN(width));
        View childDst1(2*width, 2*height, View::Gray8, NULL, TEST_ALIGN(width));
        View childDst2(2*width, 2*height, View::Gray8, NULL, TEST_ALIGN(width));
        FillRandomMask(parent, currentIndex);
        FillRandom(childSrc, 0, currentIndex - 1);
        FillRandom(difference);

        TEST_EXECUTE_AT_LEAST_MIN_TIME(f1.Call(parent, childSrc, childDst1, difference, currentIndex, invalidIndex, emptyIndex, differenceThreshold));

        TEST_EXECUTE_AT_LEAST_MIN_TIME(f2.Call(parent, childSrc, childDst2, difference, currentIndex, invalidIndex, emptyIndex, differenceThreshold));

        result = result && Compare(childDst1, childDst2, 0, true, 64);

        return result;
    }