
Hi all ! I would like to know, when creating an image like that: rgb32f_image_t img(w, h); is the image filled with 0 by default or should I call fill_pixels ? Thank you ! Eloi.

Hi Eloi, for performance reasons gil is not initializing the array with a default value. Also, I wouldn't trust the compiler to do anything special since it might be different from platform to platform. Just call fill_pixels which in your case ( rgb32f_image_t ) should be reduced to a memset call. Regards, Christian On Wed, Jan 13, 2010 at 7:37 AM, Eloi Du Bois <eloi.du.bois@gmail.com> wrote:
Hi all !
I would like to know, when creating an image like that: rgb32f_image_t img(w, h);
is the image filled with 0 by default or should I call fill_pixels ?
Thank you ! Eloi.
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

I tried to do a fill_pixels, but the thing is I get an error (because I am doing special things) on something like this: typedef pixel<bits32f, devicen_layout_t< num_channels<View>::value >
comp_pixel_t; typedef image<comp_pixel_t, false, std::allocator<unsigned char> > comp_image_t; typedef typename view_type_from_pixel<comp_pixel_t>::type comp_view_t; typedef typename comp_view_t::x_iterator tmp_iterator;
comp_image_t itmp( dst.dimensions( ) ); comp_view_t tmpv( view( itmp ) ); fill_pixels(tmpv, 0); But this is not working... Anyway, thank you Eloi. 2010/1/13 Christian Henning <chhenning@gmail.com>
Hi Eloi, for performance reasons gil is not initializing the array with a default value. Also, I wouldn't trust the compiler to do anything special since it might be different from platform to platform. Just call fill_pixels which in your case ( rgb32f_image_t ) should be reduced to a memset call.
Regards, Christian
On Wed, Jan 13, 2010 at 7:37 AM, Eloi Du Bois <eloi.du.bois@gmail.com> wrote:
Hi all !
I would like to know, when creating an image like that: rgb32f_image_t img(w, h);
is the image filled with 0 by default or should I call fill_pixels ?
Thank you ! Eloi.
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

Please use: fill_pixels( tmpv, comp_pixel_t( 0.f, 0.f, 0.f )); This call wont be a memset unfortunately. But you could always just get the char* and memset yourself. Regards, Christian On Wed, Jan 13, 2010 at 11:40 AM, Eloi Du Bois <eloi.du.bois@gmail.com> wrote:
I tried to do a fill_pixels, but the thing is I get an error (because I am doing special things) on something like this:
typedef pixel<bits32f, devicen_layout_t< num_channels<View>::value >
comp_pixel_t; typedef image<comp_pixel_t, false, std::allocator<unsigned char> > comp_image_t; typedef typename view_type_from_pixel<comp_pixel_t>::type comp_view_t; typedef typename comp_view_t::x_iterator tmp_iterator;
comp_image_t itmp( dst.dimensions( ) ); comp_view_t tmpv( view( itmp ) ); fill_pixels(tmpv, 0);
But this is not working...
Anyway, thank you Eloi.
2010/1/13 Christian Henning <chhenning@gmail.com>
Hi Eloi, for performance reasons gil is not initializing the array with a default value. Also, I wouldn't trust the compiler to do anything special since it might be different from platform to platform. Just call fill_pixels which in your case ( rgb32f_image_t ) should be reduced to a memset call.
Regards, Christian
On Wed, Jan 13, 2010 at 7:37 AM, Eloi Du Bois <eloi.du.bois@gmail.com> wrote:
Hi all !
I would like to know, when creating an image like that: rgb32f_image_t img(w, h);
is the image filled with 0 by default or should I call fill_pixels ?
Thank you ! Eloi.
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

Okay, I see. But the problem is that I don't know the pixel number of channel. It have to be full generic. That's why I am trying this (unsuccessfully): comp_pixel_t black; color_convert( bgil::gray8_pixel_t( 0 ), black ); fill_pixels( tmpv, black); 2010/1/13 Christian Henning <chhenning@gmail.com>
Please use:
fill_pixels( tmpv, comp_pixel_t( 0.f, 0.f, 0.f ));
This call wont be a memset unfortunately. But you could always just get the char* and memset yourself.
Regards, Christian
On Wed, Jan 13, 2010 at 11:40 AM, Eloi Du Bois <eloi.du.bois@gmail.com> wrote:
I tried to do a fill_pixels, but the thing is I get an error (because I am doing special things) on something like this:
typedef pixel<bits32f, devicen_layout_t< num_channels<View>::value >
comp_pixel_t; typedef image<comp_pixel_t, false, std::allocator<unsigned char>
comp_image_t; typedef typename view_type_from_pixel<comp_pixel_t>::type comp_view_t; typedef typename comp_view_t::x_iterator tmp_iterator;
comp_image_t itmp( dst.dimensions( ) ); comp_view_t tmpv( view( itmp ) ); fill_pixels(tmpv, 0);
But this is not working...
Anyway, thank you Eloi.
2010/1/13 Christian Henning <chhenning@gmail.com>
Hi Eloi, for performance reasons gil is not initializing the array with a default value. Also, I wouldn't trust the compiler to do anything special since it might be different from platform to platform. Just call fill_pixels which in your case ( rgb32f_image_t ) should be reduced to a memset call.
Regards, Christian
On Wed, Jan 13, 2010 at 7:37 AM, Eloi Du Bois <eloi.du.bois@gmail.com> wrote:
Hi all !
I would like to know, when creating an image like that: rgb32f_image_t img(w, h);
is the image filled with 0 by default or should I call fill_pixels ?
Thank you ! Eloi.
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

Eloi, this would be my solution. Wording might be a little off but I'm sure you'll get the idea: #include <boost\gil\gil_all.hpp> using namespace std; using namespace boost; using namespace gil; template< typename Data, int N > struct black_pixel_factory { BOOST_STATIC_ASSERT(( false )); }; template< typename Data > struct black_pixel_factory< Data, 1 > { typedef pixel< Data, devicen_layout_t< 1 > > pixel_t; static const pixel_t black() { return pixel_t( 0 ); } }; template< typename Data > struct black_pixel_factory< Data, 2 > { typedef pixel< Data, devicen_layout_t< 2 > > pixel_t; static const pixel_t black() { return pixel_t( 0, 0 ); } }; template< typename Data > struct black_pixel_factory< Data, 3 > { typedef pixel< Data, devicen_layout_t< 3 > > pixel_t; static const pixel_t black() { return pixel_t( 0, 0, 0 ); } }; template< typename Data > struct black_pixel_factory< Data, 4 > { typedef pixel< Data, devicen_layout_t< 4 > > pixel_t; static const pixel_t black() { return pixel_t( 0, 0, 0, 0 ); } }; template< typename Data > struct black_pixel_factory< Data, 5 > { typedef pixel< Data, devicen_layout_t< 5 > > pixel_t; static const pixel_t black() { return pixel_t( 0, 0, 0, 0, 0 ); } }; template< typename View > void foo( const View& dst ) { typedef pixel<bits32f, devicen_layout_t< num_channels<View>::value
comp_pixel_t; typedef image<comp_pixel_t, false, std::allocator<unsigned char> > comp_image_t; typedef typename view_type_from_pixel<comp_pixel_t>::type comp_view_t; typedef typename comp_view_t::x_iterator tmp_iterator;
typedef black_pixel_factory< bits32f, num_channels<View>::value > black_pixel_factory_t; typename black_pixel_factory_t::pixel_t black = black_pixel_factory_t::black(); comp_image_t itmp( dst.dimensions( ) ); comp_view_t tmpv( view( itmp ) ); fill_pixels( tmpv, black); return; } int main() { rgb32f_image_t img; foo( view( img )); return 0; } Christian

Depending on if you can rely on a boost gil extension, numeric/pixel_numeric_operations.hpp has a zero_channels function. This would give (untested) : comp_pixel_t black; zero_channels( black ); fill_pixels( tmpv, black ); Cheers, Nicolas On Wed, Jan 13, 2010 at 9:45 PM, Eloi Du Bois <eloi.du.bois@gmail.com>wrote:
Okay, I see. But the problem is that I don't know the pixel number of channel. It have to be full generic. That's why I am trying this (unsuccessfully): comp_pixel_t black; color_convert( bgil::gray8_pixel_t( 0 ), black ); fill_pixels( tmpv, black);

GIL core provides channel-level equivalents for some STL algorithms, including std::fill. These have the “static_” prefix since they are compile-time recursive: rgb8_pixel_t p; static_fill(p, 10); assert(p == rgb8_pixel_t(10,10,10)); http://stlab.adobe.com/gil/html/group___color_base_algorithm_fill.html Lubomir On 1/13/10 11:24 PM, "Nicolas Lelong" <rotoglup@gmail.com> wrote: Depending on if you can rely on a boost gil extension, numeric/pixel_numeric_operations.hpp has a zero_channels function. This would give (untested) : comp_pixel_t black; zero_channels( black ); fill_pixels( tmpv, black ); Cheers, Nicolas On Wed, Jan 13, 2010 at 9:45 PM, Eloi Du Bois <eloi.du.bois@gmail.com> wrote: Okay, I see. But the problem is that I don't know the pixel number of channel. It have to be full generic. That's why I am trying this (unsuccessfully): comp_pixel_t black; color_convert( bgil::gray8_pixel_t( 0 ), black ); fill_pixels( tmpv, black);

That is a very good idea :) Thank you very much ! Eloi. 2010/1/14 Lubomir Bourdev <lbourdev@adobe.com>
GIL core provides channel-level equivalents for some STL algorithms, including std::fill. These have the “static_” prefix since they are compile-time recursive:
rgb8_pixel_t p; static_fill(p, 10); assert(p == rgb8_pixel_t(10,10,10));
http://stlab.adobe.com/gil/html/group___color_base_algorithm_fill.html
Lubomir
On 1/13/10 11:24 PM, "Nicolas Lelong" <rotoglup@gmail.com> wrote:
Depending on if you can rely on a boost gil extension, numeric/pixel_numeric_operations.hpp has a zero_channels function.
This would give (untested) :
comp_pixel_t black; zero_channels( black ); fill_pixels( tmpv, black );
Cheers, Nicolas
On Wed, Jan 13, 2010 at 9:45 PM, Eloi Du Bois <eloi.du.bois@gmail.com> wrote:
Okay, I see. But the problem is that I don't know the pixel number of channel. It have to be full generic. That's why I am trying this (unsuccessfully): comp_pixel_t black; color_convert( bgil::gray8_pixel_t( 0 ), black ); fill_pixels( tmpv, black);
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (4)
-
Christian Henning
-
Eloi Du Bois
-
Lubomir Bourdev
-
Nicolas Lelong