[Haskell-cafe] Arrays and image processing

Anthony Cowley acowley at seas.upenn.edu
Wed Aug 4 11:12:43 EDT 2010


On Wed, Aug 4, 2010 at 12:49 AM, kirstin penelope rhys
<kirstin at speakeasy.net> wrote:
> But now I need a fast multidimensional array which can handle a tuple of
> primitive types.
>
> My options, as far an I can see, are:
>
> 1) Add an instance for UArray (Int,Int) (Word16, Word16, Word16)
> and/or UArray (Int,Int) (Word8, Word8, Word8)
>
> 2) Add a multidimensional wrapper for Data.Vector

What about something like,

import qualified Data.Vector.Unboxed as V
import Data.Word

type Pixel = (Word8, Word8, Word8)
type Image = (Int, Int, V.Vector Pixel)


Since you may want interoperability with C, you could also consider
using Data.Vector.Storable with flat data. Just put the
multi-dimensional logic in your indexing operations. I do quite a bit
of image processing with a mix of Haskell and C, and have found
Unboxed and Storable Vectors effective.

Anthony


More information about the Haskell-Cafe mailing list