
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
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
comp_pixel_t; typedef image
comp_image_t; typedef typename view_type_from_pixel ::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
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
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
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
comp_pixel_t; typedef image
comp_image_t; typedef typename view_type_from_pixel ::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
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
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
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
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
comp_pixel_t; typedef image
comp_image_t; typedef typename view_type_from_pixel
::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
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
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 comp_pixel_t;
typedef image 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
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"

That is a very good idea :)
Thank you very much !
Eloi.
2010/1/14 Lubomir Bourdev
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"
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
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