## Re: [Vxl-users] how to convert from grey to rgb?

 Re: [Vxl-users] how to convert from grey to rgb? From: Szabolcs Berecz - 2006-03-06 14:44:33 ```On 3/6/06, Amitha Perera wrote: > The problem is that vil generally prefers to treat images as > multi-planar, so that a 3-component RGB image is regarded as a 3-plane > image with a planestep of 1 (i.e. interleaved planes). If you have > your rgb image from your function and write > vil_image_view rgb_planes =3D rgb; > you'd get an image such that > rgb_planes(i,j,0) =3D=3D rgb(i,j).r && > rgb_planes(i,j,1) =3D=3D rgb(i,j).g && > rgb_planes(i,j,2) =3D=3D rgb(i,j).b > > (This won't actually copy data, so you don't have to worry about > efficiency.) You should be able to save this planar image. > > Amitha. > Thanks for the explanation! Szabi ```

### Thread view

 [Vxl-users] how to convert from grey to rgb? From: Szabolcs Berecz - 2006-03-04 23:42:35 ```Hi! I have a grayscale image: vil_image_view grey; and want to convert to rgb. I tried this: vil_image_view > rgb =3D grey; but obviously it's not working. I tried lots of functions from vxl to do the conversion, but without success. I also wrote a function which should do the conversion, but it doesn't work... void convert_grey_to_rgb(const vil_image_view &grey, vil_image_view > &rgb) { =09rgb.set_size(grey.ni(), grey.nj()); =09for (unsigned x =3D 0; x < grey.ni(); x++) =09=09for (unsigned y =3D 0; y < grey.nj(); y++) { =09=09=09vxl_byte v =3D grey(x, y); =09=09=09rgb(x, y) =3D vil_rgb(v, v, v); =09=09} } The problem is, I can't save images converted with this function. With png format I get the error message: ERROR! vil_png_file_format::make_output_image() Pixel format should be byte, but is vil_rgb instead. vil_new: Cannot new to type [png] /misc/src/VXL/vxl-1.4.0/core/vil/vil_save.cxx: (vil_save) Cannot save to type [png] With tiff: the format of the file is vil_rgb and no of components is1 WARNING: vil_tiff_image::put_view Failed because TIFF image has incorrect component size. So, how should I do it? Bye, Szabi ```
 Re: [Vxl-users] how to convert from grey to rgb? From: Amitha Perera - 2006-03-06 14:36:51 ```Szabolcs Berecz wrote about converting a greyscale image to vil_image_view > and saving it: > The problem is, I can't save images converted with this function. With > png format I get the error message: > > ERROR! vil_png_file_format::make_output_image() > Pixel format should be byte, but is vil_rgb instead. > vil_new: Cannot new to type [png] The problem is that vil generally prefers to treat images as multi-planar, so that a 3-component RGB image is regarded as a 3-plane image with a planestep of 1 (i.e. interleaved planes). If you have your rgb image from your function and write vil_image_view rgb_planes = rgb; you'd get an image such that rgb_planes(i,j,0) == rgb(i,j).r && rgb_planes(i,j,1) == rgb(i,j).g && rgb_planes(i,j,2) == rgb(i,j).b (This won't actually copy data, so you don't have to worry about efficiency.) You should be able to save this planar image. Amitha. ```
 Re: [Vxl-users] how to convert from grey to rgb? From: Szabolcs Berecz - 2006-03-06 14:44:33 ```On 3/6/06, Amitha Perera wrote: > The problem is that vil generally prefers to treat images as > multi-planar, so that a 3-component RGB image is regarded as a 3-plane > image with a planestep of 1 (i.e. interleaved planes). If you have > your rgb image from your function and write > vil_image_view rgb_planes =3D rgb; > you'd get an image such that > rgb_planes(i,j,0) =3D=3D rgb(i,j).r && > rgb_planes(i,j,1) =3D=3D rgb(i,j).g && > rgb_planes(i,j,2) =3D=3D rgb(i,j).b > > (This won't actually copy data, so you don't have to worry about > efficiency.) You should be able to save this planar image. > > Amitha. > Thanks for the explanation! Szabi ```
 Re: [Vxl-users] how to convert from grey to rgb? From: Ian Scott - 2006-03-13 12:32:51 Attachments: Attached Message ```Whilst Amitha is correct, there is a general fix to VXL for this problem, which I thought I had committed about a month ago. It is committed now, and there is a copy of the patch in the attached email. Ian. Amitha Perera wrote: > Szabolcs Berecz wrote about converting a greyscale image to > vil_image_view > and saving it: > >>The problem is, I can't save images converted with this function. With >>png format I get the error message: >> >>ERROR! vil_png_file_format::make_output_image() >>Pixel format should be byte, but is vil_rgb instead. >>vil_new: Cannot new to type [png] > > > The problem is that vil generally prefers to treat images as > multi-planar, so that a 3-component RGB image is regarded as a 3-plane > image with a planestep of 1 (i.e. interleaved planes). If you have > your rgb image from your function and write > vil_image_view rgb_planes = rgb; > you'd get an image such that > rgb_planes(i,j,0) == rgb(i,j).r && > rgb_planes(i,j,1) == rgb(i,j).g && > rgb_planes(i,j,2) == rgb(i,j).b > > (This won't actually copy data, so you don't have to worry about > efficiency.) You should be able to save this planar image. > > Amitha. > > > ------------------------------------------------------- > This SF.Net email is sponsored by xPML, a groundbreaking scripting language > that extends applications into web and mobile media. Attend the live webcast > and join the prime developer group breaking into this new coding territory! > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642 > _______________________________________________ > Vxl-users mailing list > Vxl-users@... > https://lists.sourceforge.net/lists/listinfo/vxl-users ```

## Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks