Book Image

Haskell Data Analysis Cookbook

By : Nishant Shukla
Book Image

Haskell Data Analysis Cookbook

By: Nishant Shukla

Overview of this book

Table of Contents (19 chapters)
Haskell Data Analysis Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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…

  1. 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)
  2. Read the images, process...