Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r82768 - trunk/libs/gil/toolbox/test
From: chhenning_at_[hidden]
Date: 2013-02-06 20:32:06


Author: chhenning
Date: 2013-02-06 20:32:04 EST (Wed, 06 Feb 2013)
New Revision: 82768
URL: http://svn.boost.org/trac/boost/changeset/82768

Log:
Toolbox tests and documentation.
Added:
   trunk/libs/gil/toolbox/test/Jamfile.v2 (contents, props changed)
   trunk/libs/gil/toolbox/test/channel_type.cpp (contents, props changed)
   trunk/libs/gil/toolbox/test/channel_view.cpp (contents, props changed)
   trunk/libs/gil/toolbox/test/cmyka.cpp (contents, props changed)
   trunk/libs/gil/toolbox/test/get_num_bits.cpp (contents, props changed)
   trunk/libs/gil/toolbox/test/get_pixel_type.cpp (contents, props changed)
   trunk/libs/gil/toolbox/test/gray_alpha.cpp (contents, props changed)
   trunk/libs/gil/toolbox/test/gray_to_rgba.cpp (contents, props changed)
   trunk/libs/gil/toolbox/test/hsl_hsv_test.cpp (contents, props changed)
   trunk/libs/gil/toolbox/test/indexed_image_test.cpp (contents, props changed)
   trunk/libs/gil/toolbox/test/is_bit_aligned.cpp (contents, props changed)
   trunk/libs/gil/toolbox/test/is_homogeneous.cpp (contents, props changed)
   trunk/libs/gil/toolbox/test/is_similar.cpp (contents, props changed)
   trunk/libs/gil/toolbox/test/lab_test.cpp (contents, props changed)
   trunk/libs/gil/toolbox/test/pixel_bit_size.cpp (contents, props changed)
   trunk/libs/gil/toolbox/test/rgb_to_luminance.cpp (contents, props changed)
   trunk/libs/gil/toolbox/test/test.cpp (contents, props changed)
   trunk/libs/gil/toolbox/test/xyz_test.cpp (contents, props changed)

Added: trunk/libs/gil/toolbox/test/Jamfile.v2
==============================================================================
--- (empty file)
+++ trunk/libs/gil/toolbox/test/Jamfile.v2 2013-02-06 20:32:04 EST (Wed, 06 Feb 2013)
@@ -0,0 +1,55 @@
+# Boost.GIL.ToolBox
+#
+# (C) Copyright 2012: Mateusz Loskot and Christian Henning
+#
+# Distributed under the Boost Software License, Version 1.0.
+# (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+# bring in rules for testing
+import testing ;
+
+project
+ : requirements
+ <library>/boost/test//boost_unit_test_framework
+ <link>static
+ <include>../../../..
+ <toolset>intel:<debug-symbols>off
+ <toolset>msvc-7.1:<debug-symbols>off
+ <toolset>msvc-8.0:<define>_SCL_SECURE_NO_DEPRECATE <define>_CRT_SECURE_NO_DEPRECATE <define>_CRT_NONSTDC_NO_DEPRECATE
+ <toolset>msvc-9.0:<define>_SCL_SECURE_NO_DEPRECATE <define>_CRT_SECURE_NO_WARNINGS <define>_CRT_NONSTDC_NO_DEPRECATE
+ <toolset>msvc-10.0:<define>_SCL_SECURE_NO_DEPRECATE <define>_CRT_SECURE_NO_WARNINGS <define>_CRT_NONSTDC_NO_DEPRECATE
+ <link>static
+ <library>/boost/test//boost_unit_test_framework
+# <library>/boost/system//boost_system
+ ;
+
+test-suite "gil::toolbox"
+ :
+ [ run
+ # sources
+ test.cpp
+ channel_type.cpp
+ channel_view.cpp
+ cmyka.cpp
+ get_num_bits.cpp
+ get_pixel_type.cpp
+ gray_alpha.cpp
+ gray_to_rgba.cpp
+ hsl_hsv_test.cpp
+ indexed_image_test.cpp
+ is_bit_aligned.cpp
+ is_homogeneous.cpp
+ is_similar.cpp
+ lab_test.cpp
+ pixel_bit_size.cpp
+ rgb_to_luminance.cpp
+ xyz_test.cpp
+ : # args
+ : # input-files
+ : # requirements
+ : # target-name
+ gil_io_new_tests
+ : # default-build
+ ]
+
+ ;

Added: trunk/libs/gil/toolbox/test/channel_type.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/gil/toolbox/test/channel_type.cpp 2013-02-06 20:32:04 EST (Wed, 06 Feb 2013)
@@ -0,0 +1,24 @@
+#include <boost/test/unit_test.hpp>
+
+#include <boost/type_traits/is_same.hpp>
+
+#include <boost/gil/extension/toolbox/metafunctions/channel_type.hpp>
+
+using namespace boost;
+using namespace gil;
+
+BOOST_AUTO_TEST_SUITE( channel_type_test )
+
+BOOST_AUTO_TEST_CASE( channel_type_test )
+{
+ BOOST_STATIC_ASSERT(( is_same< unsigned char, channel_type< rgb8_pixel_t >::type >::value ));
+
+ // bits32f is a scoped_channel_value object
+ BOOST_STATIC_ASSERT(( is_same< bits32f, channel_type< rgba32f_pixel_t >::type >::value ));
+
+ // channel_type for bit_aligned images doesn't work with standard gil.
+ typedef bit_aligned_image4_type<4, 4, 4, 4, rgb_layout_t>::type image_t;
+ typedef channel_type< image_t::view_t::reference >::type channel_t;
+}
+
+BOOST_AUTO_TEST_SUITE_END()

Added: trunk/libs/gil/toolbox/test/channel_view.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/gil/toolbox/test/channel_view.cpp 2013-02-06 20:32:04 EST (Wed, 06 Feb 2013)
@@ -0,0 +1,30 @@
+#include <boost/test/unit_test.hpp>
+
+#include <boost/type_traits/is_same.hpp>
+
+#include <boost/gil/extension/toolbox/metafunctions/channel_view.hpp>
+
+using namespace boost;
+using namespace gil;
+
+BOOST_AUTO_TEST_SUITE( channel_view_test )
+
+BOOST_AUTO_TEST_CASE( channel_view_test )
+{
+ typedef rgb8_image_t image_t;
+
+ image_t img( 100, 100 );
+
+ typedef kth_channel_view_type< 0, rgb8_view_t::const_t >::type view_t;
+ view_t red = kth_channel_view<0>( const_view( img ));
+
+ typedef channel_view_type< red_t, rgb8_view_t::const_t >::type channel_view_t;
+ channel_view_t red_ = channel_view< red_t >( const_view( img ));
+
+ BOOST_STATIC_ASSERT(( is_same< kth_channel_view_type< 0, const rgb8_view_t>::type
+ , channel_view_type< red_t, const rgb8_view_t>::type
+ >::value
+ ));
+}
+
+BOOST_AUTO_TEST_SUITE_END()

Added: trunk/libs/gil/toolbox/test/cmyka.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/gil/toolbox/test/cmyka.cpp 2013-02-06 20:32:04 EST (Wed, 06 Feb 2013)
@@ -0,0 +1,25 @@
+#include <boost/test/unit_test.hpp>
+
+#include <boost/type_traits/is_same.hpp>
+
+#include <boost/gil/extension/toolbox/color_spaces/cmyka.hpp>
+
+using namespace boost;
+using namespace gil;
+
+BOOST_AUTO_TEST_SUITE( cmyka_test )
+
+BOOST_AUTO_TEST_CASE( cmyka_test )
+{
+ cmyka8_pixel_t a( 10, 20, 30, 40, 50 );
+ rgba8_pixel_t b;
+ cmyka8_pixel_t c;
+
+ color_convert( a, b );
+
+ // no rgba to cmyka conversion implemented
+ //color_convert( b, c );
+ //BOOST_ASSERT( at_c<0>(a) == at_c<0>(c) );
+}
+
+BOOST_AUTO_TEST_SUITE_END()

Added: trunk/libs/gil/toolbox/test/get_num_bits.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/gil/toolbox/test/get_num_bits.cpp 2013-02-06 20:32:04 EST (Wed, 06 Feb 2013)
@@ -0,0 +1,25 @@
+#include <boost/test/unit_test.hpp>
+
+#include <boost/type_traits/is_same.hpp>
+
+#include <boost/gil/gil_all.hpp>
+#include <boost/gil/extension/toolbox/metafunctions/channel_type.hpp>
+#include <boost/gil/extension/toolbox/metafunctions/get_num_bits.hpp>
+
+using namespace boost;
+using namespace gil;
+
+BOOST_AUTO_TEST_SUITE( get_num_bits_test )
+
+BOOST_AUTO_TEST_CASE( get_num_bits_test )
+{
+ typedef bit_aligned_image4_type<4, 4, 4, 4, rgb_layout_t>::type image_t;
+
+ typedef channel_type< image_t::view_t::reference >::type channel_t;
+ BOOST_STATIC_ASSERT( get_num_bits< channel_t >::value == 4 );
+
+ typedef channel_type< image_t::const_view_t::reference >::type const_channel_t;
+ BOOST_STATIC_ASSERT( get_num_bits< const_channel_t >::value == 4 );
+}
+
+BOOST_AUTO_TEST_SUITE_END()

Added: trunk/libs/gil/toolbox/test/get_pixel_type.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/gil/toolbox/test/get_pixel_type.cpp 2013-02-06 20:32:04 EST (Wed, 06 Feb 2013)
@@ -0,0 +1,30 @@
+#include <boost/test/unit_test.hpp>
+
+#include <boost/type_traits/is_same.hpp>
+
+#include <boost/gil/gil_all.hpp>
+#include <boost/gil/extension/toolbox/metafunctions/get_pixel_type.hpp>
+
+using namespace boost;
+using namespace gil;
+
+BOOST_AUTO_TEST_SUITE( get_pixel_type_test )
+
+BOOST_AUTO_TEST_CASE( get_pixel_type_test )
+{
+ {
+ typedef bit_aligned_image3_type< 4, 15, 4, rgb_layout_t >::type image_t;
+ BOOST_STATIC_ASSERT(( is_same< get_pixel_type< image_t::view_t >::type
+ , image_t::view_t::reference >::value
+ ));
+ }
+
+ {
+ typedef rgb8_image_t image_t;
+ BOOST_STATIC_ASSERT(( is_same< get_pixel_type< image_t::view_t >::type
+ , image_t::view_t::value_type >::value
+ ));
+ }
+}
+
+BOOST_AUTO_TEST_SUITE_END()

Added: trunk/libs/gil/toolbox/test/gray_alpha.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/gil/toolbox/test/gray_alpha.cpp 2013-02-06 20:32:04 EST (Wed, 06 Feb 2013)
@@ -0,0 +1,38 @@
+#include <boost/test/unit_test.hpp>
+
+#include <boost/type_traits/is_same.hpp>
+
+#include <boost/gil/extension/toolbox/color_spaces/gray_alpha.hpp>
+
+using namespace boost;
+using namespace gil;
+
+BOOST_AUTO_TEST_SUITE( gray_alpha_test )
+
+BOOST_AUTO_TEST_CASE( gray_alpha_test )
+{
+ {
+ gray_alpha8_pixel_t a( 10, 20 );
+ gray8_pixel_t b;
+
+ color_convert( a, b );
+ }
+
+ {
+ gray_alpha8_pixel_t a( 10, 20 );
+ rgb8_pixel_t b;
+ gray_alpha8_pixel_t c;
+
+ color_convert( a, b );
+ }
+
+ {
+ gray_alpha8_pixel_t a( 10, 20 );
+ rgba8_pixel_t b;
+ gray_alpha8_pixel_t c;
+
+ color_convert( a, b );
+ }
+}
+
+BOOST_AUTO_TEST_SUITE_END()

Added: trunk/libs/gil/toolbox/test/gray_to_rgba.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/gil/toolbox/test/gray_to_rgba.cpp 2013-02-06 20:32:04 EST (Wed, 06 Feb 2013)
@@ -0,0 +1,22 @@
+#include <boost/test/unit_test.hpp>
+
+#include <boost/type_traits/is_same.hpp>
+
+#include <boost/gil/gil_all.hpp>
+#include <boost/gil/extension/toolbox/color_converters/gray_to_rgba.hpp>
+
+using namespace boost;
+using namespace gil;
+
+BOOST_AUTO_TEST_SUITE( gray_to_rgba_test )
+
+BOOST_AUTO_TEST_CASE( gray_to_rgba_test )
+{
+ gray8_pixel_t a( 45 );
+ rgba8_pixel_t b;
+
+ color_convert( a, b );
+
+}
+
+BOOST_AUTO_TEST_SUITE_END()

Added: trunk/libs/gil/toolbox/test/hsl_hsv_test.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/gil/toolbox/test/hsl_hsv_test.cpp 2013-02-06 20:32:04 EST (Wed, 06 Feb 2013)
@@ -0,0 +1,75 @@
+// Copyright 2012 Christian Henning
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+/// \brief Unit test for hsl and hsv color spaces
+
+#include <boost/gil/gil_all.hpp>
+#include <boost/gil/extension/toolbox/color_spaces/hsl.hpp>
+#include <boost/gil/extension/toolbox/color_spaces/hsv.hpp>
+
+#include <boost/test/unit_test.hpp>
+
+using namespace std;
+using namespace boost;
+using namespace gil;
+
+BOOST_AUTO_TEST_SUITE( hsl_hsv_test_suite )
+
+BOOST_AUTO_TEST_CASE( hsl_hsv_test )
+{
+ {
+ rgb8_pixel_t p( 128, 0, 128 );
+
+ hsl32f_pixel_t h;
+
+ color_convert( p, h );
+ color_convert( h, p );
+ }
+
+ {
+ size_t width = 640;
+ size_t height = 480;
+
+ hsl32f_image_t hsl_img( width, height );
+ hsv32f_image_t hsv_img( width, height );
+
+ for( size_t y = 0; y < height; y++ )
+ {
+ hsl32f_view_t::x_iterator hsl_x_it = view( hsl_img ).row_begin( y );
+ hsv32f_view_t::x_iterator hsv_x_it = view( hsv_img ).row_begin( y );
+
+ float v = static_cast<float>( height - y )
+ / height;
+
+ for( size_t x = 0; x < width; x++ )
+ {
+ float hue = ( x + 1.f ) / width;
+
+ hsl_x_it[x] = hsl32f_pixel_t( hue, 1.0, v );
+ hsv_x_it[x] = hsv32f_pixel_t( hue, 1.0, v );
+ }
+ }
+ }
+
+ {
+ rgb8_image_t rgb_img( 640, 480 );
+ fill_pixels( view(rgb_img), rgb8_pixel_t( 255, 128, 64 ));
+ hsl32f_image_t hsl_img( view( rgb_img ).dimensions() );
+
+ copy_pixels( color_converted_view<hsl32f_pixel_t>( view( rgb_img ))
+ , view( hsl_img ));
+ }
+
+ {
+ rgb8_image_t rgb_img( 640, 480 );
+ fill_pixels( view(rgb_img), rgb8_pixel_t( 255, 128, 64 ));
+ hsv32f_image_t hsv_img( view( rgb_img ).dimensions() );
+
+ copy_pixels( color_converted_view<hsv32f_pixel_t>( view( rgb_img ))
+ , view( hsv_img ));
+ }
+}
+
+BOOST_AUTO_TEST_SUITE_END()

Added: trunk/libs/gil/toolbox/test/indexed_image_test.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/gil/toolbox/test/indexed_image_test.cpp 2013-02-06 20:32:04 EST (Wed, 06 Feb 2013)
@@ -0,0 +1,116 @@
+// Copyright 2012 Christian Henning
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+/// \brief Unit test for indexed_image type.
+
+#include <boost/test/unit_test.hpp>
+
+#include <boost/gil/gil_all.hpp>
+#include <boost/gil/extension/toolbox/image_types/indexed_image.hpp>
+
+
+using namespace std;
+using namespace boost;
+using namespace gil;
+
+
+BOOST_AUTO_TEST_SUITE( index_image_test_suite )
+
+BOOST_AUTO_TEST_CASE( index_image_test )
+{
+ {
+ indexed_image< uint8_t, rgb8_pixel_t > img( 640, 480 );
+ fill_pixels( view( img ), rgb8_pixel_t( 255, 0, 0 ));
+
+ rgb8_pixel_t p = *view( img ).xy_at( 10, 10 );
+ }
+
+ {
+
+ indexed_image< gray8_pixel_t, rgb8_pixel_t > img( 640, 480, 256 );
+
+ //generate_pixels( img.get_indices_view()
+ // , [] () -> uint8_t
+ // {
+ // static uint8_t i = 0;
+ // i = ( i == 256 ) ? 0 : ++i;
+
+ // return gray8_pixel_t( i );
+ // }
+ // );
+
+
+ //generate_pixels( img.get_palette_view()
+ // , [] () ->rgb8_pixel_t
+ // {
+ // static uint8_t i = 0;
+ // i = ( i == 256 ) ? 0 : ++i;
+
+ // return rgb8_pixel_t( i, i, i );
+ // }
+ // );
+
+ int i = ( 640 * 10 + 10 ) % 256;
+
+ gray8_pixel_t index = *img.get_indices_view().xy_at( 10 , 1 );
+ rgb8_pixel_t color = *img.get_palette_view().xy_at( index, 0 );
+
+ rgb8_pixel_t p = *view( img ).xy_at( 10, 1 );
+
+ i = 9;
+ }
+
+ {
+ indexed_image< uint8_t, rgb8_pixel_t > img( 640, 480, 256 );
+
+ //generate_pixels( img.get_indices_view()
+ // , [] () -> uint8_t
+ // {
+ // static uint8_t i = 0;
+ // i = ( i == 256 ) ? 0 : ++i;
+
+ // return i;
+ // }
+ // );
+
+
+ //generate_pixels( img.get_palette_view()
+ // , [] () ->rgb8_pixel_t
+ // {
+ // static uint8_t i = 0;
+ // i = ( i == 256 ) ? 0 : ++i;
+
+ // return rgb8_pixel_t( i, i, i );
+ // }
+ // );
+
+ int i = ( 640 * 10 + 10 ) % 256;
+
+ uint8_t index = *img.get_indices_view().xy_at( 10 , 1 );
+ rgb8_pixel_t color = *img.get_palette_view().xy_at( index, 0 );
+
+ rgb8_pixel_t p = *view( img ).xy_at( 10, 1 );
+
+ i = 9;
+ }
+
+ {
+ typedef indexed_image< uint8_t, rgb8_pixel_t > image_t;
+ image_t img( 640, 480, 256 );
+
+ for( image_t::y_coord_t y = 0; y < view( img ).height(); ++y )
+ {
+ image_t::view_t::x_iterator it = view( img ).row_begin( y );
+
+ for( image_t::x_coord_t x = 0; x < view( img ).width(); ++x )
+ {
+ rgb8_pixel_t p = *it;
+ it++;
+ }
+ }
+ }
+}
+
+BOOST_AUTO_TEST_SUITE_END()

Added: trunk/libs/gil/toolbox/test/is_bit_aligned.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/gil/toolbox/test/is_bit_aligned.cpp 2013-02-06 20:32:04 EST (Wed, 06 Feb 2013)
@@ -0,0 +1,19 @@
+#include <boost/test/unit_test.hpp>
+
+#include <boost/type_traits/is_same.hpp>
+
+#include <boost/gil/gil_all.hpp>
+#include <boost/gil/extension/toolbox/metafunctions/is_bit_aligned.hpp>
+
+using namespace boost;
+using namespace gil;
+
+BOOST_AUTO_TEST_SUITE( is_bit_aligned_test )
+
+BOOST_AUTO_TEST_CASE( is_bit_aligned_test )
+{
+ typedef bit_aligned_image1_type< 4, gray_layout_t>::type image_t;
+ BOOST_STATIC_ASSERT(( is_bit_aligned< image_t::view_t::value_type >::value ));
+}
+
+BOOST_AUTO_TEST_SUITE_END()

Added: trunk/libs/gil/toolbox/test/is_homogeneous.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/gil/toolbox/test/is_homogeneous.cpp 2013-02-06 20:32:04 EST (Wed, 06 Feb 2013)
@@ -0,0 +1,21 @@
+#include <boost/test/unit_test.hpp>
+
+#include <boost/gil/gil_all.hpp>
+#include <boost/gil/extension/toolbox/metafunctions/is_homogeneous.hpp>
+
+using namespace boost;
+using namespace gil;
+
+BOOST_AUTO_TEST_SUITE( is_homogeneous_test )
+
+BOOST_AUTO_TEST_CASE( is_homogeneous_test )
+{
+ BOOST_STATIC_ASSERT(( is_homogeneous< rgb8_pixel_t >::value ));
+
+ BOOST_STATIC_ASSERT(( is_homogeneous< cmyk16c_planar_ref_t >::value ));
+
+ typedef bit_aligned_image1_type< 4, gray_layout_t>::type image_t;
+ BOOST_STATIC_ASSERT(( is_homogeneous< image_t::view_t::reference >::value ));
+}
+
+BOOST_AUTO_TEST_SUITE_END()

Added: trunk/libs/gil/toolbox/test/is_similar.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/gil/toolbox/test/is_similar.cpp 2013-02-06 20:32:04 EST (Wed, 06 Feb 2013)
@@ -0,0 +1,15 @@
+#include <boost/test/unit_test.hpp>
+
+#include <boost/gil/gil_all.hpp>
+#include <boost/gil/extension/toolbox/metafunctions/is_similar.hpp>
+
+using namespace boost;
+using namespace gil;
+
+BOOST_AUTO_TEST_SUITE( is_similar_test )
+
+BOOST_AUTO_TEST_CASE( is_similar_test )
+{
+}
+
+BOOST_AUTO_TEST_SUITE_END()

Added: trunk/libs/gil/toolbox/test/lab_test.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/gil/toolbox/test/lab_test.cpp 2013-02-06 20:32:04 EST (Wed, 06 Feb 2013)
@@ -0,0 +1,167 @@
+// Copyright 2012 Davide Anastasia
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+/// \file lab_test.cpp
+/// \brief Unit test for LAB Colorspace
+/// \author Davide Anastasia <davideanastasia_at_[hidden]>
+
+#include <boost/test/unit_test.hpp>
+
+#define TEST_CHECK_CLOSE(a, b) \
+ BOOST_CHECK_CLOSE(a, b, 0.0005f)
+
+#include <iostream>
+#include <boost/gil/gil_all.hpp>
+#include <boost/gil/extension/toolbox/color_spaces/lab.hpp>
+
+using namespace boost;
+
+BOOST_AUTO_TEST_SUITE(Lab_Test)
+
+BOOST_AUTO_TEST_CASE(Lab_to_XYZ_Test1)
+{
+ gil::lab32f_pixel_t lab_pixel(40.366198f, 53.354489f, 26.117702f);
+ gil::xyz32f_pixel_t xyz_pixel;
+
+ gil::color_convert(lab_pixel, xyz_pixel);
+
+ TEST_CHECK_CLOSE(static_cast<float>(xyz_pixel[0]), 0.197823f);
+ TEST_CHECK_CLOSE(static_cast<float>(xyz_pixel[1]), 0.114731f);
+ TEST_CHECK_CLOSE(static_cast<float>(xyz_pixel[2]), 0.048848f);
+}
+
+BOOST_AUTO_TEST_CASE(Lab_to_XYZ_Test2)
+{
+ gil::lab32f_pixel_t lab_pixel(50, 0, 0);
+ gil::xyz32f_pixel_t xyz_pixel;
+
+ gil::color_convert(lab_pixel, xyz_pixel);
+
+ TEST_CHECK_CLOSE(static_cast<float>(xyz_pixel[0]), 0.175064f);
+ TEST_CHECK_CLOSE(static_cast<float>(xyz_pixel[1]), 0.184187f);
+ TEST_CHECK_CLOSE(static_cast<float>(xyz_pixel[2]), 0.200548f);
+}
+
+BOOST_AUTO_TEST_CASE(XYZ_to_Lab_Test1)
+{
+ gil::lab32f_pixel_t lab_pixel;
+ gil::xyz32f_pixel_t xyz_pixel(0.085703f, 0.064716f, 0.147082f);
+
+ gil::color_convert(xyz_pixel, lab_pixel);
+
+ TEST_CHECK_CLOSE(static_cast<float>(lab_pixel[0]), 30.572438f);
+ TEST_CHECK_CLOSE(static_cast<float>(lab_pixel[1]), 23.4674f);
+ TEST_CHECK_CLOSE(static_cast<float>(lab_pixel[2]), -22.322275f);
+}
+
+BOOST_AUTO_TEST_CASE(RGB_to_Lab_Test1)
+{
+ gil::rgb32f_pixel_t rgb_pixel(0.75f, 0.5f, 0.25f);
+ gil::lab32f_pixel_t lab_pixel;
+
+ gil::color_convert(rgb_pixel, lab_pixel);
+
+ TEST_CHECK_CLOSE(static_cast<float>(lab_pixel[0]), 58.7767f);
+ TEST_CHECK_CLOSE(static_cast<float>(lab_pixel[1]), 18.5851f);
+ TEST_CHECK_CLOSE(static_cast<float>(lab_pixel[2]), 43.7975f);
+}
+
+BOOST_AUTO_TEST_CASE(RGB_to_Lab_Test2)
+{
+ gil::rgb32f_pixel_t rgb_pixel(1.f, 0.f, 0.f);
+ gil::lab32f_pixel_t lab_pixel;
+
+ gil::color_convert(rgb_pixel, lab_pixel);
+
+ TEST_CHECK_CLOSE(static_cast<float>(lab_pixel[0]), 53.2408f);
+ TEST_CHECK_CLOSE(static_cast<float>(lab_pixel[1]), 80.0925f);
+ TEST_CHECK_CLOSE(static_cast<float>(lab_pixel[2]), 67.2032f);
+}
+
+BOOST_AUTO_TEST_CASE(RGB_to_Lab_Test3)
+{
+ gil::rgb32f_pixel_t rgb_pixel(0.f, 1.f, 0.f);
+ gil::lab32f_pixel_t lab_pixel;
+
+ gil::color_convert(rgb_pixel, lab_pixel);
+
+ TEST_CHECK_CLOSE(static_cast<float>(lab_pixel[0]), 87.7347f);
+ TEST_CHECK_CLOSE(static_cast<float>(lab_pixel[1]), -86.1827f);
+ TEST_CHECK_CLOSE(static_cast<float>(lab_pixel[2]), 83.1793f);
+}
+
+BOOST_AUTO_TEST_CASE(RGB_to_Lab_Test4)
+{
+ gil::rgb32f_pixel_t rgb_pixel(0.f, 0.f, 1.f);
+ gil::lab32f_pixel_t lab_pixel;
+
+ gil::color_convert(rgb_pixel, lab_pixel);
+
+ TEST_CHECK_CLOSE(static_cast<float>(lab_pixel[0]), 32.2970f);
+ TEST_CHECK_CLOSE(static_cast<float>(lab_pixel[1]), 79.1875f);
+ TEST_CHECK_CLOSE(static_cast<float>(lab_pixel[2]), -107.8602f);
+}
+
+BOOST_AUTO_TEST_CASE(RGB_to_Lab_Test5)
+{
+ gil::rgb32f_pixel_t rgb_pixel(1.f, 1.f, 1.f);
+ gil::lab32f_pixel_t lab_pixel;
+
+ gil::color_convert(rgb_pixel, lab_pixel);
+
+ TEST_CHECK_CLOSE(static_cast<float>(lab_pixel[0]), 100.f);
+ TEST_CHECK_CLOSE(static_cast<float>(lab_pixel[1]), 0.f);
+ TEST_CHECK_CLOSE(static_cast<float>(lab_pixel[2]), 0.f);
+}
+
+BOOST_AUTO_TEST_CASE(Lab_to_RGB_Test1)
+{
+ gil::lab32f_pixel_t lab_pixel(75.f, 20.f, 40.f);
+ gil::rgb32f_pixel_t rgb_pixel;
+
+ gil::color_convert(lab_pixel, rgb_pixel);
+
+ TEST_CHECK_CLOSE(static_cast<float>(rgb_pixel[0]), 0.943240f);
+ TEST_CHECK_CLOSE(static_cast<float>(rgb_pixel[1]), 0.663990f);
+ TEST_CHECK_CLOSE(static_cast<float>(rgb_pixel[2]), 0.437893f);
+}
+
+BOOST_AUTO_TEST_CASE(Lab_to_RGB_Test2)
+{
+ gil::lab32f_pixel_t lab_pixel(100.f, 0.f, 0.f);
+ gil::rgb32f_pixel_t rgb_pixel;
+
+ gil::color_convert(lab_pixel, rgb_pixel);
+
+ TEST_CHECK_CLOSE(static_cast<float>(rgb_pixel[0]), 1.f);
+ TEST_CHECK_CLOSE(static_cast<float>(rgb_pixel[1]), 1.f);
+ TEST_CHECK_CLOSE(static_cast<float>(rgb_pixel[2]), 1.f);
+}
+
+BOOST_AUTO_TEST_CASE(Lab_to_RGB_Test3)
+{
+ gil::lab32f_pixel_t lab_pixel(56.8140f, -42.3665f, 10.6728f);
+ gil::rgb32f_pixel_t rgb_pixel;
+
+ gil::color_convert(lab_pixel, rgb_pixel);
+
+ TEST_CHECK_CLOSE(static_cast<float>(rgb_pixel[0]), 0.099999f);
+ TEST_CHECK_CLOSE(static_cast<float>(rgb_pixel[1]), 0.605568f);
+ TEST_CHECK_CLOSE(static_cast<float>(rgb_pixel[2]), 0.456662f);
+}
+
+BOOST_AUTO_TEST_CASE(Lab_to_RGB_Test4)
+{
+ gil::lab32f_pixel_t lab_pixel(50.5874f, 4.0347f, 50.5456f);
+ gil::rgb32f_pixel_t rgb_pixel;
+
+ gil::color_convert(lab_pixel, rgb_pixel);
+
+ TEST_CHECK_CLOSE(static_cast<float>(rgb_pixel[0]), 0.582705f);
+ TEST_CHECK_CLOSE(static_cast<float>(rgb_pixel[1]), 0.454891f);
+ TEST_CHECK_CLOSE(static_cast<float>(rgb_pixel[2]), 0.1f);
+}
+
+BOOST_AUTO_TEST_SUITE_END()

Added: trunk/libs/gil/toolbox/test/pixel_bit_size.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/gil/toolbox/test/pixel_bit_size.cpp 2013-02-06 20:32:04 EST (Wed, 06 Feb 2013)
@@ -0,0 +1,17 @@
+#include <boost/test/unit_test.hpp>
+
+#include <boost/gil/gil_all.hpp>
+#include <boost/gil/extension/toolbox/metafunctions/pixel_bit_size.hpp>
+
+using namespace boost;
+using namespace gil;
+
+BOOST_AUTO_TEST_SUITE( pixel_bit_size_test )
+
+BOOST_AUTO_TEST_CASE( pixel_bit_size_test )
+{
+ typedef bit_aligned_image5_type< 16, 16, 16, 8, 8, devicen_layout_t< 5 > >::type image_t;
+ BOOST_STATIC_ASSERT(( pixel_bit_size<image_t::view_t::reference>::value == 64 ));
+}
+
+BOOST_AUTO_TEST_SUITE_END()

Added: trunk/libs/gil/toolbox/test/rgb_to_luminance.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/gil/toolbox/test/rgb_to_luminance.cpp 2013-02-06 20:32:04 EST (Wed, 06 Feb 2013)
@@ -0,0 +1,27 @@
+#include <boost/test/unit_test.hpp>
+
+#include <boost/gil/gil_all.hpp>
+#include <boost/gil/extension/toolbox/color_converters/rgb_to_luminance.hpp>
+
+using namespace boost;
+using namespace gil;
+
+struct double_zero { static double apply() { return 0.0; } };
+struct double_one { static double apply() { return 1.0; } };
+
+typedef scoped_channel_value< double, double_zero, double_one > bits64f;
+
+typedef pixel< double, gray_layout_t > gray64f_pixel_t;
+typedef pixel< double, rgb_layout_t > rgb64f_pixel_t;
+
+BOOST_AUTO_TEST_SUITE( rgb_to_luminance_test )
+
+BOOST_AUTO_TEST_CASE( rgb_to_luminance_test )
+{
+ rgb64f_pixel_t a( 10, 20, 30 );
+ gray64f_pixel_t b;
+
+ color_convert( a, b );
+}
+
+BOOST_AUTO_TEST_SUITE_END()

Added: trunk/libs/gil/toolbox/test/test.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/gil/toolbox/test/test.cpp 2013-02-06 20:32:04 EST (Wed, 06 Feb 2013)
@@ -0,0 +1,2 @@
+#define BOOST_TEST_MAIN
+#include <boost/test/unit_test.hpp>

Added: trunk/libs/gil/toolbox/test/xyz_test.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/gil/toolbox/test/xyz_test.cpp 2013-02-06 20:32:04 EST (Wed, 06 Feb 2013)
@@ -0,0 +1,193 @@
+// Copyright 2012 Davide Anastasia
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+/// \file xyz_test.cpp
+/// \brief Unit test for XYZ Colorspace
+/// \author Davide Anastasia <davideanastasia_at_[hidden]>
+
+#include <iostream>
+#include <limits>
+#include <boost/cstdint.hpp>
+#include <boost/gil/gil_all.hpp>
+#include <boost/gil/extension/toolbox/color_spaces/xyz.hpp>
+
+#include <boost/test/unit_test.hpp>
+
+using namespace boost;
+using namespace std;
+
+const float SKEW = 0.0001f;
+
+BOOST_AUTO_TEST_SUITE(ColorSpaceConversionXYZ)
+
+BOOST_AUTO_TEST_CASE(rgb32f_xyz32f_1)
+{
+ gil::xyz32f_pixel_t xyz32f;
+ gil::rgb32f_pixel_t p32f(.934351f, 0.785446f, .105858f), p32f_b;
+ gil::color_convert(p32f, xyz32f);
+ gil::color_convert(xyz32f, p32f_b);
+
+ BOOST_TEST_MESSAGE( p32f[0] << " "
+ << p32f[1] << " "
+ << p32f[2] << " -> "
+ << xyz32f[0] << " "
+ << xyz32f[1] << " "
+ << xyz32f[2] << " -> "
+ << p32f_b[0] << " "
+ << p32f_b[1] << " "
+ << p32f_b[2] );
+
+ BOOST_CHECK( abs(p32f[0] - p32f_b[0]) < SKEW );
+ BOOST_CHECK( abs(p32f[1] - p32f_b[1]) < SKEW );
+ BOOST_CHECK( abs(p32f[2] - p32f_b[2]) < SKEW );
+ BOOST_CHECK( abs( xyz32f[0] - 0.562669) < SKEW );
+ BOOST_CHECK( abs( xyz32f[1] - 0.597462) < SKEW );
+ BOOST_CHECK( abs( xyz32f[2] - 0.096050) < SKEW );
+}
+
+BOOST_AUTO_TEST_CASE(rgb32f_xyz32f_2)
+{
+ gil::xyz32f_pixel_t xyz32f;
+ gil::rgb32f_pixel_t p32f(.694617f, 0.173810f, 0.218710f), p32f_b;
+ gil::color_convert(p32f, xyz32f);
+ gil::color_convert(xyz32f, p32f_b);
+
+ BOOST_TEST_MESSAGE( p32f[0] << " "
+ << p32f[1] << " "
+ << p32f[2] << " -> "
+ << xyz32f[0] << " "
+ << xyz32f[1] << " "
+ << xyz32f[2] << " -> "
+ << p32f_b[0] << " "
+ << p32f_b[1] << " "
+ << p32f_b[2] );
+
+ BOOST_CHECK( abs(p32f[0] - p32f_b[0]) < SKEW );
+ BOOST_CHECK( abs(p32f[1] - p32f_b[1]) < SKEW );
+ BOOST_CHECK( abs(p32f[2] - p32f_b[2]) < SKEW );
+ BOOST_CHECK( abs( xyz32f[0] - 0.197823) < SKEW );
+ BOOST_CHECK( abs( xyz32f[1] - 0.114731) < SKEW );
+ BOOST_CHECK( abs( xyz32f[2] - 0.048848) < SKEW );
+}
+
+BOOST_AUTO_TEST_CASE(xyz32f_rgb32f_1)
+{
+ gil::xyz32f_pixel_t xyz32f(.332634f, .436288f, .109853f), xyz32f_b;
+ gil::rgb32f_pixel_t p32f;
+ gil::color_convert(xyz32f, p32f);
+ gil::color_convert(p32f, xyz32f_b);
+
+ BOOST_TEST_MESSAGE( xyz32f[0] << " "
+ << xyz32f[1] << " "
+ << xyz32f[2] << " -> "
+ << p32f[0] << " "
+ << p32f[1] << " "
+ << p32f[2] << " -> "
+ << xyz32f_b[0] << " "
+ << xyz32f_b[1] << " "
+ << xyz32f_b[2] );
+
+ BOOST_CHECK( abs(xyz32f_b[0] - xyz32f[0]) < SKEW );
+ BOOST_CHECK( abs(xyz32f_b[1] - xyz32f[1]) < SKEW );
+ BOOST_CHECK( abs(xyz32f_b[2] - xyz32f[2]) < SKEW );
+ BOOST_CHECK( abs( p32f[0] - 0.628242) < SKEW );
+ BOOST_CHECK( abs( p32f[1] - 0.735771) < SKEW );
+ BOOST_CHECK( abs( p32f[2] - 0.236473) < SKEW );
+}
+
+BOOST_AUTO_TEST_CASE(xyz32f_rgb32f_2)
+{
+ gil::xyz32f_pixel_t xyz32f(.375155f, .352705f, .260025f), xyz32f_b;
+ gil::rgb32f_pixel_t p32f;
+ gil::color_convert(xyz32f, p32f);
+ gil::color_convert(p32f, xyz32f_b);
+
+ BOOST_TEST_MESSAGE( xyz32f[0] << " "
+ << xyz32f[1] << " "
+ << xyz32f[2] << " -> "
+ << p32f[0] << " "
+ << p32f[1] << " "
+ << p32f[2] << " -> "
+ << xyz32f_b[0] << " "
+ << xyz32f_b[1] << " "
+ << xyz32f_b[2] );
+
+ BOOST_CHECK( abs(xyz32f_b[0] - xyz32f[0]) < SKEW );
+ BOOST_CHECK( abs(xyz32f_b[1] - xyz32f[1]) < SKEW );
+ BOOST_CHECK( abs(xyz32f_b[2] - xyz32f[2]) < SKEW );
+ BOOST_CHECK( abs( p32f[0] - 0.763580) < SKEW );
+ BOOST_CHECK( abs( p32f[1] - 0.591622) < SKEW );
+ BOOST_CHECK( abs( p32f[2] - 0.510392) < SKEW );
+}
+
+BOOST_AUTO_TEST_CASE(rgb8u_xyz32f_1)
+{
+ gil::xyz32f_pixel_t xyz32f;
+ gil::rgb8_pixel_t p8u(177, 44, 56), p8u_b;
+ gil::color_convert(p8u, xyz32f);
+ gil::color_convert(xyz32f, p8u_b);
+
+ BOOST_TEST_MESSAGE( static_cast<int>(p8u[0]) << " "
+ << static_cast<int>(p8u[1]) << " "
+ << static_cast<int>(p8u[2]) << " -> "
+ << xyz32f[0] << " "
+ << xyz32f[1] << " "
+ << xyz32f[2] << " -> "
+ << static_cast<int>(p8u_b[0]) << " "
+ << static_cast<int>(p8u_b[1]) << " "
+ << static_cast<int>(p8u_b[2]) );
+
+ BOOST_CHECK(p8u[0] == p8u_b[0]);
+ BOOST_CHECK(p8u[1] == p8u_b[1]);
+ BOOST_CHECK(p8u[2] == p8u_b[2]);
+}
+
+BOOST_AUTO_TEST_CASE(rgb8u_xyz32f_2)
+{
+ gil::xyz32f_pixel_t xyz32f;
+ gil::rgb8_pixel_t p8u(72, 90, 165), p8u_b;
+ gil::color_convert(p8u, xyz32f);
+ gil::color_convert(xyz32f, p8u_b);
+
+ BOOST_TEST_MESSAGE(
+ static_cast<int>(p8u[0]) << " "
+ << static_cast<int>(p8u[1]) << " "
+ << static_cast<int>(p8u[2]) << " -> "
+ << xyz32f[0] << " "
+ << xyz32f[1] << " "
+ << xyz32f[2] << " -> "
+ << static_cast<int>(p8u_b[0]) << " "
+ << static_cast<int>(p8u_b[1]) << " "
+ << static_cast<int>(p8u_b[2]) );
+
+ BOOST_CHECK(p8u[0] == p8u_b[0]);
+ BOOST_CHECK(p8u[1] == p8u_b[1]);
+ BOOST_CHECK(p8u[2] == p8u_b[2]);
+}
+
+BOOST_AUTO_TEST_CASE(rgb16u_xyz32f_1)
+{
+ gil::xyz32f_pixel_t xyz32f;
+ gil::rgb16_pixel_t p16u(12564, 20657, 200), p16u_b;
+ gil::color_convert(p16u, xyz32f);
+ gil::color_convert(xyz32f, p16u_b);
+
+ BOOST_TEST_MESSAGE(
+ static_cast<int>(p16u[0]) << " "
+ << static_cast<int>(p16u[1]) << " "
+ << static_cast<int>(p16u[2]) << " -> "
+ << xyz32f[0] << " "
+ << xyz32f[1] << " "
+ << xyz32f[2] << " -> "
+ << static_cast<int>(p16u_b[0]) << " "
+ << static_cast<int>(p16u_b[1]) << " "
+ << static_cast<int>(p16u_b[2]) );
+
+ BOOST_CHECK(p16u[0] == p16u_b[0]);
+ BOOST_CHECK(p16u[1] == p16u_b[1]);
+ BOOST_CHECK(p16u[2] == p16u_b[2]);
+}
+
+BOOST_AUTO_TEST_SUITE_END()


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk