I am looking for a no-pixel-copy way to get a gray8(C)_view_t from a single channel of a argb8(C)_view_t. Unfortunately I have to use an API that I cannot change and that expects a gray8_view_t as input, whereas my image data is ARGB8 and the data needed is always one of the source channels.
I tried using nth_channel_view() which seems not to be usable as gray8_view_t. Since my code is targeted for mobile platforms, there are certain restrictions in terms of memory usage and processing speed, so a cheap view-only solution would be really great. Do you have any suggestion?
Thank you in advance
Andreas
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
unfortunately the API I have to use is frozen. It takes argb8(C)_view_t for the pixel data and gray8(C)_view_t's for certain masks to further qualify image areas. My source data is always ARGB8, even for the masks (one or more channels are used as masks). My hope was to get a gray8(C)_view_t with a step iterator that operates directly on my ARGB8 source data.
As mioskot suggested, I also thought of using a color_converted_view, but that would mean a performance slowdown, since the algorithm is quite complex and iterates multiple times over the pixel data. That said, it may indeed be better to copy pixels over to a gray8-based image.
Best,
Andreas
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2012-11-03
Andreas, why can you not use the view type generated by nth_channel_view? It seems you can use a color_converted_view type.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2012-11-06
Hi Andreas,
just from the look of it I would argue that the resulting type of a color_converted_view is not the same as gray8_view_t. Even if the color_converted_view is a single channel view. Remember that the your view type has to jump differently through the memory than an ordinary gray8_view_t.
Try to give your getMaskView a templated return type.
Hi,
I am looking for a no-pixel-copy way to get a gray8(C)_view_t from a single channel of a argb8(C)_view_t. Unfortunately I have to use an API that I cannot change and that expects a gray8_view_t as input, whereas my image data is ARGB8 and the data needed is always one of the source channels.
I tried using nth_channel_view() which seems not to be usable as gray8_view_t. Since my code is targeted for mobile platforms, there are certain restrictions in terms of memory usage and processing speed, so a cheap view-only solution would be really great. Do you have any suggestion?
Thank you in advance
Andreas
See the example of use of color_converted_view in the tutorial
http://www.boost.org/doc/libs/1_51_0/libs/gil/doc/html/giltutorial.html#ColorConversionSec
Hi Andreas,
am I understanding correctly that your API only takes the input parameter of type gray8(C)_view_t? No other view type is allowed?
If that's the case you prob will have copy the data somewhere to create a gray8_view_t.
Let me know,
Christain
Hi Christian,
thank you for answering!
unfortunately the API I have to use is frozen. It takes argb8(C)_view_t for the pixel data and gray8(C)_view_t's for certain masks to further qualify image areas. My source data is always ARGB8, even for the masks (one or more channels are used as masks). My hope was to get a gray8(C)_view_t with a step iterator that operates directly on my ARGB8 source data.
As mioskot suggested, I also thought of using a color_converted_view, but that would mean a performance slowdown, since the algorithm is quite complex and iterates multiple times over the pixel data. That said, it may indeed be better to copy pixels over to a gray8-based image.
Best,
Andreas
Andreas, why can you not use the view type generated by nth_channel_view? It seems you can use a color_converted_view type.
This might help:
argb8_image_t img( 640, 480 );
fill_pixels(view(img), argb8_pixel_t(0, 255, 0, 0 ));
auto v = nth_channel_view( view(img), 1 );
auto c = color_converted_view<gray8_pixel_t>( v );
auto p = v;
Christian
Thank you Christian, I will give that a try.
Best,
Andreas
Hi Christian,
this is my code:
Where _argb8View is declared as:
When I compile it, I get the following error:
Do you have any idea?
Thanks in advance,
Andreas
Hi Andreas,
just from the look of it I would argue that the resulting type of a color_converted_view is not the same as gray8_view_t. Even if the color_converted_view is a single channel view. Remember that the your view type has to jump differently through the memory than an ordinary gray8_view_t.
Try to give your getMaskView a templated return type.
template< typename View >
View Test::getMaskView(…) { … }
Hope that helps,
Christian