.. only:: html
.. note::
:class: sphx-glr-download-link-note
Click :ref:`here ` to download the full example code
.. rst-class:: sphx-glr-example-title
.. _sphx_glr_examples_imaging_swap_red_and_blue.py:
Swap Red and Blue Image Channels
================================
.. code-block:: default
import numpy as np
import imagepypelines as ip
ip.require('image')
ip.set_log_level('debug')
.. code-block:: default
# swap red and blue color channels
@ip.blockify()
def swap_red_and_blue(image):
return np.flip(image, axis=2)
Define our tasks and build the pipeline
.. code-block:: default
tasks = {
# set an entry point for images into the pipeline
'images': ip.Input(),
# swap channels
'swapped': (swap_red_and_blue, 'images'),
# Scale the images, cast dtype, and view the image comparisons!
'safe': (ip.image.DisplaySafe(), 'swapped'),
'null' : (ip.image.CompareView(pause_for=5000), 'images','safe')
}
swap = ip.Pipeline(tasks)
Let's process some data!
------------------------
Let's grab some example data from the ImagePypelines standard set
.. code-block:: default
images = [ip.image.panda(), ip.image.gecko(), ip.image.redhat()]
# Number and view the images!
processed = swap.process(images)
.. image:: /examples/imaging/images/sphx_glr_swap_red_and_blue_001.png
:alt: Image1, Image2
:class: sphx-glr-single-img
.. rst-class:: sphx-glr-timing
**Total running time of the script:** ( 0 minutes 15.776 seconds)
.. _sphx_glr_download_examples_imaging_swap_red_and_blue.py:
.. only :: html
.. container:: sphx-glr-footer
:class: sphx-glr-footer-example
.. container:: sphx-glr-download sphx-glr-download-python
:download:`Download Python source code: swap_red_and_blue.py `
.. container:: sphx-glr-download sphx-glr-download-jupyter
:download:`Download Jupyter notebook: swap_red_and_blue.ipynb `
.. only:: html
.. rst-class:: sphx-glr-signature
`Gallery generated by Sphinx-Gallery `_