hip-1.1.0.1: Haskell Image Processing (HIP) Library.

Copyright (c) Alexey Kuleshevich 2016 BSD3 Alexey Kuleshevich experimental non-portable None Haskell2010

Graphics.Image.Interface.Vector

Contents

Description

Synopsis

# Construction

Arguments

 :: Array VU cs Double => (Int, Int) (m rows, n columns) - dimensions of a new image. -> ((Int, Int) -> Pixel cs Double) A function that takes (i-th row, and j-th column) as an argument and returns a pixel for that location. -> Image VU cs Double

Create an image with VU (Vector Unboxed) representation and pixels of Double precision. Note, that for Double precision pixels it is essential to keep values normalized in the [0, 1] range in order for an image to be written to file properly.

>>> let grad_gray = makeImage (200, 200) (\(i, j) -> PixelY (fromIntegral i)/200 * (fromIntegral j)/200)


Because all Pixels and Images are installed into Num, above is equivalent to:

>>> let grad_gray = makeImage (200, 200) (\(i, j) -> PixelY $fromIntegral (i*j)) / (200*200) >>> writeImage "images/grad_gray.png" grad_gray  Creating color images is just as easy. >>> let grad_color = makeImage (200, 200) (\(i, j) -> PixelRGB (fromIntegral i) (fromIntegral j) (fromIntegral (i + j))) / 400 >>> writeImage "images/grad_color.png" grad_color  fromLists :: Array VU cs e => [[Pixel cs e]] -> Image VU cs e Source # Construct an image from a nested rectangular shaped list of pixels. Length of an outer list will constitute m rows, while the length of inner lists - n columns. All of the inner lists must be the same length and greater than 0. >>> fromLists [[PixelY (fromIntegral (i*j) / 60000) | j <- [1..300]] | i <- [1..200]] <Image VectorUnboxed Y (Double): 200x300>  fromUnboxedVector :: Array VU cs e => (Int, Int) -> Vector (Pixel cs e) -> Image VU cs e Source # Construct a two dimensional image with m rows and n columns from a flat Unboxed Vector of length k. It is a O(1) opeartion. Make sure that m * n = k. >>> fromUnboxedVector (200, 300)$ generate 60000 (\i -> PixelY $fromIntegral i / 60000) <Image VectorUnboxed Luma: 200x300>  toUnboxedVector :: Array VU cs e => Image VU cs e -> Vector (Pixel cs e) Source # Convert an image to a flattened Unboxed Vector. It is a O(1) opeartion. >>> toUnboxedVector$ makeImage (3, 2) (\(i, j) -> PixelY \$ fromIntegral (i+j))
fromList [<Luma:(0.0)>,<Luma:(1.0)>,<Luma:(1.0)>,<Luma:(2.0)>,<Luma:(2.0)>,<Luma:(3.0)>]


# IO

Read image as luma (brightness).

Read image as luma with Alpha channel.

Read image in RGB colorspace.

Read image in RGB colorspace with Alpha channel.

# Representation

data VU Source #

Unboxed Vector representation.

Constructors

 VU

Instances

 Source # MethodsshowsPrec :: Int -> VU -> ShowS #show :: VU -> String #showList :: [VU] -> ShowS # Source # O(1) - Changes to Repa representation. Methodsexchange :: (Array VU cs e, Array RS cs e) => RS -> Image VU cs e -> Image RS cs e Source # Source # O(1) - Changes to Repa representation. Methodsexchange :: (Array VU cs e, Array RP cs e) => RP -> Image VU cs e -> Image RP cs e Source # Source # O(1) - Changes to Vector representation. Methodsexchange :: (Array RS cs e, Array VU cs e) => VU -> Image RS cs e -> Image VU cs e Source # Source # O(1) - Changes to Vector representation. Methodsexchange :: (Array RP cs e, Array VU cs e) => VU -> Image RP cs e -> Image VU cs e Source # ManifestArray VU cs e => MutableArray VU cs e Source # Associated Typesdata MImage st VU cs e :: * Source # Methodsmdims :: MImage st VU cs e -> (Int, Int) Source #thaw :: (Functor m, PrimMonad m) => Image VU cs e -> m (MImage (PrimState m) VU cs e) Source #freeze :: (Functor m, PrimMonad m) => MImage (PrimState m) VU cs e -> m (Image VU cs e) Source #new :: (Functor m, PrimMonad m) => (Int, Int) -> m (MImage (PrimState m) VU cs e) Source #read :: (Functor m, PrimMonad m) => MImage (PrimState m) VU cs e -> (Int, Int) -> m (Pixel cs e) Source #write :: (Functor m, PrimMonad m) => MImage (PrimState m) VU cs e -> (Int, Int) -> Pixel cs e -> m () Source #swap :: (Functor m, PrimMonad m) => MImage (PrimState m) VU cs e -> (Int, Int) -> (Int, Int) -> m () Source # ManifestArray VU cs e => SequentialArray VU cs e Source # Methodsfoldl :: (a -> Pixel cs e -> a) -> a -> Image VU cs e -> a Source #foldr :: (Pixel cs e -> a -> a) -> a -> Image VU cs e -> a Source #mapM :: (SequentialArray VU cs' e', Functor m, Monad m) => (Pixel cs' e' -> m (Pixel cs e)) -> Image VU cs' e' -> m (Image VU cs e) Source #mapM_ :: (Functor m, Monad m) => (Pixel cs e -> m b) -> Image VU cs e -> m () Source #foldM :: (Functor m, Monad m) => (a -> Pixel cs e -> m a) -> a -> Image VU cs e -> m a Source #foldM_ :: (Functor m, Monad m) => (a -> Pixel cs e -> m a) -> a -> Image VU cs e -> m () Source # Array VU cs e => ManifestArray VU cs e Source # Methodsindex :: Image VU cs e -> (Int, Int) -> Pixel cs e Source #deepSeqImage :: Image VU cs e -> a -> a Source #(|*|) :: Image VU cs e -> Image VU cs e -> Image VU cs e Source #fold :: (Pixel cs e -> Pixel cs e -> Pixel cs e) -> Pixel cs e -> Image VU cs e -> Pixel cs e Source #eq :: Image VU cs e -> Image VU cs e -> Bool Source # Elt VU cs e => Array VU cs e Source # Associated Typestype Elt VU cs e :: Constraint Source #data Image VU cs e :: * Source # MethodsmakeImage :: (Int, Int) -> ((Int, Int) -> Pixel cs e) -> Image VU cs e Source #singleton :: Pixel cs e -> Image VU cs e Source #dims :: Image VU cs e -> (Int, Int) Source #map :: Array VU cs' e' => (Pixel cs' e' -> Pixel cs e) -> Image VU cs' e' -> Image VU cs e Source #imap :: Array VU cs' e' => ((Int, Int) -> Pixel cs' e' -> Pixel cs e) -> Image VU cs' e' -> Image VU cs e Source #zipWith :: (Array VU cs1 e1, Array VU cs2 e2) => (Pixel cs1 e1 -> Pixel cs2 e2 -> Pixel cs e) -> Image VU cs1 e1 -> Image VU cs2 e2 -> Image VU cs e Source #izipWith :: (Array VU cs1 e1, Array VU cs2 e2) => ((Int, Int) -> Pixel cs1 e1 -> Pixel cs2 e2 -> Pixel cs e) -> Image VU cs1 e1 -> Image VU cs2 e2 -> Image VU cs e Source #traverse :: Array VU cs' e' => Image VU cs' e' -> ((Int, Int) -> (Int, Int)) -> (((Int, Int) -> Pixel cs' e') -> (Int, Int) -> Pixel cs e) -> Image VU cs e Source #traverse2 :: (Array VU cs1 e1, Array VU cs2 e2) => Image VU cs1 e1 -> Image VU cs2 e2 -> ((Int, Int) -> (Int, Int) -> (Int, Int)) -> (((Int, Int) -> Pixel cs1 e1) -> ((Int, Int) -> Pixel cs2 e2) -> (Int, Int) -> Pixel cs e) -> Image VU cs e Source #transpose :: Image VU cs e -> Image VU cs e Source #backpermute :: (Int, Int) -> ((Int, Int) -> (Int, Int)) -> Image VU cs e -> Image VU cs e Source #fromLists :: [[Pixel cs e]] -> Image VU cs e Source # data Image VU Source # data Image VU = VScalar !(Pixel cs e)| VUImage !Int !Int !(Vector (Pixel cs e)) data MImage st VU Source # data MImage st VU = MVImage !Int !Int (MVector st (Pixel cs e))| MVScalar (MVector st (Pixel cs e)) type Elt VU cs e Source # type Elt VU cs e = (ColorSpace cs, Num e, Unbox e, Typeable * e, Unbox (PixelElt cs e), Unbox (Pixel cs e))