ImageBufAlgo::channels() provides a general way to copy one ImageBuf to another 
with arbitrary channel reordering, truncation, or addition/insertion of black 
channels.

It's exposed through oiiotool as the new "--ch" command, where the argument is 
a comma-separated list of channel numbers and/or names (you can mix and match).

Here are some examples of how it can be used:


Turn a single channel image into gray RGB:

    oiiotool gray.tif --ch 0,0,0 -o rgb.tif


Copy just the color from an RGBA file, truncating the A, yielding RGB only:

    oiiotool rgba.tif --ch R,G,B -o rgb.tif


Zero out the red and green channels:

    oiiotool rgb.tif --ch -1,-1,B -o justblue.tif

Swap the red and blue channels from an RGBA image:

    oiiotool rgba.tif --ch 2,1,0,3 -o bgra.tif

Extract just the named channels from a complicted many-channel image:

    oiiotool allmyaovs.exr --ch spec.R,spec.G,spec.B -o spec.exr


Along the way I also fixed a bug I recently introduced when I refactored 
IB::get_pixel_channels that messed up iv single channel viewing.

You can merge this Pull Request by running:

  git pull https://github.com/lgritz/oiio lg-channels

Or you can view, comment on it, or merge it online at:

  https://github.com/OpenImageIO/oiio/pull/418

-- Commit Summary --

* Add optional strides to ImageBuf get_pixels and get_pixel_channels.
* ImageBufAlgo::channels can select, shuffle, truncate, or extend channels.
* oiiotool --ch to select, shuffle, truncate, or extend channels.

-- File Changes --

M src/doc/oiiotool.tex (49)
M src/include/imagebuf.h (55)
M src/include/imagebufalgo.h (21)
M src/libOpenImageIO/imagebuf.cpp (32)
M src/libOpenImageIO/imagebufalgo.cpp (81)
M src/oiiotool/imagerec.cpp (22)
M src/oiiotool/oiiotool.cpp (106)
M src/oiiotool/oiiotool.h (18)

-- Patch Links --

  https://github.com/OpenImageIO/oiio/pull/418.patch
  https://github.com/OpenImageIO/oiio/pull/418.diff

---
Reply to this email directly or view it on GitHub:
https://github.com/OpenImageIO/oiio/pull/418
_______________________________________________
Oiio-dev mailing list
[email protected]
http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org

Reply via email to