/* * NICE-Core - efficient algebra and computer vision methods * - libimage - An image/template for new NICE libraries * See file License for license information. */ #ifdef NICE_USELIB_CPPUNIT #include "TestImageOperators.h" #include #include #include #include #ifdef NICE_USELIB_LIMUN_IOCOMPRESSION #include #endif using namespace NICE; using namespace std; CPPUNIT_TEST_SUITE_REGISTRATION( TestImageOperators ); void TestImageOperators::setUp() { } void TestImageOperators::tearDown() { } void TestImageOperators::testConstructor() { } void TestImageOperators::testOperators() { // inline GrayImage16s operator-(const GrayImage16s& a) { GrayImage16s img(2,2); img(0,0) = 10; img(1,0) = -15; img(0,1) = 0; img(1,1) = -33; img = -img; CPPUNIT_ASSERT_EQUAL(-10, static_cast(img(0,0))); CPPUNIT_ASSERT_EQUAL( 15, static_cast(img(1,0))); CPPUNIT_ASSERT_EQUAL( 0, static_cast(img(0,1))); CPPUNIT_ASSERT_EQUAL( 33, static_cast(img(1,1))); } // inline FloatImage& operator-=(FloatImage& a, const FloatImage& b) { FloatImage fimg1(3,3); for(int y=0; y(fimg1.getPixel(x,y)), 0.0); } // inline const FloatImage operator-(const FloatImage& a, const FloatImage& b) { FloatImage fimg1(2,2); fimg1(0,0) = -15.5; fimg1(1,0) = 3.3; fimg1(0,1) = 0.25; fimg1(1,1) = -1.7; FloatImage fimg2(2,2); fimg2(0,0) = -1.3; fimg2(1,0) = -4.5; fimg2(0,1) = 1.1; fimg2(1,1) = 0.2; FloatImage fres(2,2); fres = fimg1-fimg2; CPPUNIT_ASSERT_DOUBLES_EQUAL(-14.2, static_cast(fres.getPixel(0,0)), 0.000001); CPPUNIT_ASSERT_DOUBLES_EQUAL( 7.8, static_cast(fres.getPixel(1,0)), 0.000001); CPPUNIT_ASSERT_DOUBLES_EQUAL(-0.85, static_cast(fres.getPixel(0,1)), 0.000001); CPPUNIT_ASSERT_DOUBLES_EQUAL(- 1.9, static_cast(fres.getPixel(1,1)), 0.000001); } // inline FloatImage& operator-=(FloatImage& a, Ipp32f c) { FloatImage fimg(3,3); for(int y=0; y(fimg(x,y)), 0.000001); } // inline const FloatImage operator-(const FloatImage& a, Ipp32f c) { FloatImage fimg(3,3); for(int y=0; y(fres(x,y)), 0.000001); } // inline FloatImage& operator+=(FloatImage& a, const FloatImage& b) { FloatImage fimg1(3,3), fimg2(3,3); for(int y=0; y(fimg1(x,y)), 0.000001); } // inline GrayImage16s& operator+=(GrayImage16s& a, const Ipp16s& c) { GrayImage16s src(3,3); src.set(1); src += 5; for(int y=0; y(src(x,y))); src += (-11); for(int y=0; y(src(x,y))); } // inline const FloatImage operator+(const FloatImage& a, const FloatImage& b) { FloatImage fimg1(3,3), fimg2(3,3); for(int y=0; y(fres(x,y)), 0.000001); } // inline FloatImage& operator+=(FloatImage& a, Ipp32f c) { FloatImage fimg(3,3); for(int y=0; y(fimg(x,y)), 0.000001); } // inline const FloatImage operator+(const FloatImage& a, Ipp32f c) { FloatImage fimg(3,3); for(int y=0; y(fres(x,y)), 0.000001); } // inline FloatImage& operator*=(FloatImage& a, const FloatImage& b) { FloatImage fimg1(5,5), fimg2(5,5); for(int y=0; y(fimg1(x,y)), 0.000001); } // inline const FloatImage operator*(const FloatImage& a, const FloatImage& b) { FloatImage fimg1(5,5), fimg2(5,5); for(int y=0; y(fres(x,y)), 0.000001); } // inline FloatImage& operator*=(FloatImage& a, Ipp32f c) { FloatImage fimg(5,5); for(int y=0; y(fimg(x,y)), 0.000001); } // inline Image operator*=(Image& a, Ipp8u c) { Image gimg(5,5); for(int y=0; y(gimg(x,y))); } // inline const FloatImage operator*(const FloatImage& a, Ipp32f c) { FloatImage fimg(5,5); for(int y=0; y(fres(x,y)), 0.000001); } // inline const Image operator*(const Image& a, Ipp8u c) { Image gimg(5,5); for(int y=0; y(gres(x,y))); } // inline FloatImage& operator/=(FloatImage& a, const FloatImage& b) { FloatImage fimg1(5,5), fimg2(5,5); for(int y=0; y(fimg1(x,y)), 0.000001); } // inline const FloatImage operator/(const FloatImage& a, const FloatImage& b) { FloatImage fimg1(5,5), fimg2(5,5); for(int y=0; y(fres(x,y)), 0.000001); } // inline FloatImage& operator/=(FloatImage& a, Ipp32f c) { FloatImage fimg(5,5); for(int y=0; y(fimg(x,y)), 0.000001); } // inline const FloatImage operator/(const FloatImage& a, Ipp32f c) { FloatImage fimg(5,5); for(int y=0; y(fres(x,y)), 0.000001); } } #endif