Manipulating images in parallel using Repa
Repa is a powerful library for manipulating high-dimensional arrays in parallel. We will use it to read and edit the pixels of an image.
Getting ready
Install Developer's Image Library (DevIL), a cross-platform image manipulation toolkit. It can be downloaded from http://openil.sourceforge.net/download.php or through apt-get
on Debian systems as follows:
$ sudo apt-get install libdevil-dev
Install the Repa package from cabal for the DevIL toolkit as follows:
$ cabal install repa-devil
Create two images named image1.png
and image2.png
that have the same dimensions, which are shown as follows:
Here comes the second image:
How to do it…
- Import the following libraries as follows:
import System.Environment (getArgs) import Data.Word (Word8) import qualified Data.Array.Repa as R import Data.Array.Repa hiding ((++)) import Data.Array.Repa.IO.DevIL (runIL, readImage, writeImage, IL, Image(RGB)) import Data.Array.Repa.Repr.ForeignPtr (F)
- Read the...