friday-0.2.3.1: A functional image processing library for Haskell.

Safe HaskellNone
LanguageHaskell2010

Vision.Primitive.Shape

Contents

Description

Shapes are similar to what you could found in repa. Shape are used both for indexes and shapes.

To create a shape/index, use the ix1, ix2, ix3 ... helpers :

size = ix2 200 100

To pull values from a shape, use the Z and :. constructors :

Z :. h :. w = size
Synopsis

Documentation

class Eq sh => Shape sh where #

Class of types that can be used as array shapes and indices.

Methods

shapeRank :: sh -> Int #

Gets the number of dimensions in a shape.

shapeLength :: sh -> Int #

Gets the total number of elements in an array of this shape.

shapeZero :: sh #

Gives the first index of an array.

shapeSucc #

Arguments

:: sh

Shape of the array.

-> sh

Index.

-> sh 

Gives the successor of an index, given the shape of the array.

toLinearIndex #

Arguments

:: sh

Shape of the array.

-> sh

Index into the array.

-> Int 

Convert an index into its equivalent flat, linear, row-major version.

fromLinearIndex #

Arguments

:: sh

Shape of the array.

-> Int

Index into linear representation.

-> sh 

Inverse of toLinearIndex.

shapeList :: sh -> [sh] #

Return the ascending list of indexes for the given shape.

inShape #

Arguments

:: sh

Shape of the array.

-> sh

Index to check for.

-> Bool 

Check whether an index is within a given shape.

Instances
Shape Z # 
Instance details

Defined in Vision.Primitive.Shape

Methods

shapeRank :: Z -> Int #

shapeLength :: Z -> Int #

shapeZero :: Z #

shapeSucc :: Z -> Z -> Z #

toLinearIndex :: Z -> Z -> Int #

fromLinearIndex :: Z -> Int -> Z #

shapeList :: Z -> [Z] #

inShape :: Z -> Z -> Bool #

Shape sh => Shape (sh :. Int) # 
Instance details

Defined in Vision.Primitive.Shape

Methods

shapeRank :: (sh :. Int) -> Int #

shapeLength :: (sh :. Int) -> Int #

shapeZero :: sh :. Int #

shapeSucc :: (sh :. Int) -> (sh :. Int) -> sh :. Int #

toLinearIndex :: (sh :. Int) -> (sh :. Int) -> Int #

fromLinearIndex :: (sh :. Int) -> Int -> sh :. Int #

shapeList :: (sh :. Int) -> [sh :. Int] #

inShape :: (sh :. Int) -> (sh :. Int) -> Bool #

data Z #

An index of dimension zero.

Constructors

Z 
Instances
Eq Z # 
Instance details

Defined in Vision.Primitive.Shape

Methods

(==) :: Z -> Z -> Bool #

(/=) :: Z -> Z -> Bool #

Ord Z # 
Instance details

Defined in Vision.Primitive.Shape

Methods

compare :: Z -> Z -> Ordering #

(<) :: Z -> Z -> Bool #

(<=) :: Z -> Z -> Bool #

(>) :: Z -> Z -> Bool #

(>=) :: Z -> Z -> Bool #

max :: Z -> Z -> Z #

min :: Z -> Z -> Z #

Read Z # 
Instance details

Defined in Vision.Primitive.Shape

Show Z # 
Instance details

Defined in Vision.Primitive.Shape

Methods

showsPrec :: Int -> Z -> ShowS #

show :: Z -> String #

showList :: [Z] -> ShowS #

Storable Z # 
Instance details

Defined in Vision.Primitive.Shape

Methods

sizeOf :: Z -> Int #

alignment :: Z -> Int #

peekElemOff :: Ptr Z -> Int -> IO Z #

pokeElemOff :: Ptr Z -> Int -> Z -> IO () #

peekByteOff :: Ptr b -> Int -> IO Z #

pokeByteOff :: Ptr b -> Int -> Z -> IO () #

peek :: Ptr Z -> IO Z #

poke :: Ptr Z -> Z -> IO () #

Unbox Z # 
Instance details

Defined in Vision.Primitive.Shape

Shape Z # 
Instance details

Defined in Vision.Primitive.Shape

Methods

shapeRank :: Z -> Int #

shapeLength :: Z -> Int #

shapeZero :: Z #

shapeSucc :: Z -> Z -> Z #

toLinearIndex :: Z -> Z -> Int #

fromLinearIndex :: Z -> Int -> Z #

shapeList :: Z -> [Z] #

inShape :: Z -> Z -> Bool #

HistogramShape Z # 
Instance details

Defined in Vision.Histogram

Methods

toBin :: Z -> Z -> Z -> Z #

Vector Vector Z # 
Instance details

Defined in Vision.Primitive.Shape

MVector MVector Z # 
Instance details

Defined in Vision.Primitive.Shape

data Vector Z # 
Instance details

Defined in Vision.Primitive.Shape

data Vector Z = V_Z (Vector ())
data MVector s Z # 
Instance details

Defined in Vision.Primitive.Shape

data MVector s Z = MV_Z (MVector s ())

data tail :. head infixl 3 #

Our index type, used for both shapes and indices.

Constructors

!tail :. !head infixl 3 
Instances
(Unbox t, Unbox h) => Vector Vector (t :. h) # 
Instance details

Defined in Vision.Primitive.Shape

Methods

basicUnsafeFreeze :: PrimMonad m => Mutable Vector (PrimState m) (t :. h) -> m (Vector (t :. h)) #

basicUnsafeThaw :: PrimMonad m => Vector (t :. h) -> m (Mutable Vector (PrimState m) (t :. h)) #

basicLength :: Vector (t :. h) -> Int #

basicUnsafeSlice :: Int -> Int -> Vector (t :. h) -> Vector (t :. h) #

basicUnsafeIndexM :: Monad m => Vector (t :. h) -> Int -> m (t :. h) #

basicUnsafeCopy :: PrimMonad m => Mutable Vector (PrimState m) (t :. h) -> Vector (t :. h) -> m () #

elemseq :: Vector (t :. h) -> (t :. h) -> b -> b #

(Unbox t, Unbox h) => MVector MVector (t :. h) # 
Instance details

Defined in Vision.Primitive.Shape

Methods

basicLength :: MVector s (t :. h) -> Int #

basicUnsafeSlice :: Int -> Int -> MVector s (t :. h) -> MVector s (t :. h) #

basicOverlaps :: MVector s (t :. h) -> MVector s (t :. h) -> Bool #

basicUnsafeNew :: PrimMonad m => Int -> m (MVector (PrimState m) (t :. h)) #

basicInitialize :: PrimMonad m => MVector (PrimState m) (t :. h) -> m () #

basicUnsafeReplicate :: PrimMonad m => Int -> (t :. h) -> m (MVector (PrimState m) (t :. h)) #

basicUnsafeRead :: PrimMonad m => MVector (PrimState m) (t :. h) -> Int -> m (t :. h) #

basicUnsafeWrite :: PrimMonad m => MVector (PrimState m) (t :. h) -> Int -> (t :. h) -> m () #

basicClear :: PrimMonad m => MVector (PrimState m) (t :. h) -> m () #

basicSet :: PrimMonad m => MVector (PrimState m) (t :. h) -> (t :. h) -> m () #

basicUnsafeCopy :: PrimMonad m => MVector (PrimState m) (t :. h) -> MVector (PrimState m) (t :. h) -> m () #

basicUnsafeMove :: PrimMonad m => MVector (PrimState m) (t :. h) -> MVector (PrimState m) (t :. h) -> m () #

basicUnsafeGrow :: PrimMonad m => MVector (PrimState m) (t :. h) -> Int -> m (MVector (PrimState m) (t :. h)) #

(Eq tail, Eq head) => Eq (tail :. head) # 
Instance details

Defined in Vision.Primitive.Shape

Methods

(==) :: (tail :. head) -> (tail :. head) -> Bool #

(/=) :: (tail :. head) -> (tail :. head) -> Bool #

(Ord tail, Ord head) => Ord (tail :. head) # 
Instance details

Defined in Vision.Primitive.Shape

Methods

compare :: (tail :. head) -> (tail :. head) -> Ordering #

(<) :: (tail :. head) -> (tail :. head) -> Bool #

(<=) :: (tail :. head) -> (tail :. head) -> Bool #

(>) :: (tail :. head) -> (tail :. head) -> Bool #

(>=) :: (tail :. head) -> (tail :. head) -> Bool #

max :: (tail :. head) -> (tail :. head) -> tail :. head #

min :: (tail :. head) -> (tail :. head) -> tail :. head #

(Read tail, Read head) => Read (tail :. head) # 
Instance details

Defined in Vision.Primitive.Shape

Methods

readsPrec :: Int -> ReadS (tail :. head) #

readList :: ReadS [tail :. head] #

readPrec :: ReadPrec (tail :. head) #

readListPrec :: ReadPrec [tail :. head] #

(Show tail, Show head) => Show (tail :. head) # 
Instance details

Defined in Vision.Primitive.Shape

Methods

showsPrec :: Int -> (tail :. head) -> ShowS #

show :: (tail :. head) -> String #

showList :: [tail :. head] -> ShowS #

Storable sh => Storable (sh :. Int) # 
Instance details

Defined in Vision.Primitive.Shape

Methods

sizeOf :: (sh :. Int) -> Int #

alignment :: (sh :. Int) -> Int #

peekElemOff :: Ptr (sh :. Int) -> Int -> IO (sh :. Int) #

pokeElemOff :: Ptr (sh :. Int) -> Int -> (sh :. Int) -> IO () #

peekByteOff :: Ptr b -> Int -> IO (sh :. Int) #

pokeByteOff :: Ptr b -> Int -> (sh :. Int) -> IO () #

peek :: Ptr (sh :. Int) -> IO (sh :. Int) #

poke :: Ptr (sh :. Int) -> (sh :. Int) -> IO () #

(Unbox t, Unbox h) => Unbox (t :. h) # 
Instance details

Defined in Vision.Primitive.Shape

Shape sh => Shape (sh :. Int) # 
Instance details

Defined in Vision.Primitive.Shape

Methods

shapeRank :: (sh :. Int) -> Int #

shapeLength :: (sh :. Int) -> Int #

shapeZero :: sh :. Int #

shapeSucc :: (sh :. Int) -> (sh :. Int) -> sh :. Int #

toLinearIndex :: (sh :. Int) -> (sh :. Int) -> Int #

fromLinearIndex :: (sh :. Int) -> Int -> sh :. Int #

shapeList :: (sh :. Int) -> [sh :. Int] #

inShape :: (sh :. Int) -> (sh :. Int) -> Bool #

HistogramShape sh => HistogramShape (sh :. Int) # 
Instance details

Defined in Vision.Histogram

Methods

toBin :: (sh :. Int) -> (sh :. Int) -> (sh :. Int) -> sh :. Int #

data MVector s (t :. h) # 
Instance details

Defined in Vision.Primitive.Shape

data MVector s (t :. h) = MV_Dim (MVector s (t, h))
data Vector (t :. h) # 
Instance details

Defined in Vision.Primitive.Shape

data Vector (t :. h) = V_Dim (Vector (t, h))

Common dimensions.

type DIM0 = Z #

type DIM1 = DIM0 :. Int #

type DIM2 = DIM1 :. Int #

type DIM3 = DIM2 :. Int #

type DIM4 = DIM3 :. Int #

type DIM5 = DIM4 :. Int #

type DIM6 = DIM5 :. Int #

type DIM7 = DIM6 :. Int #

type DIM8 = DIM7 :. Int #

type DIM9 = DIM8 :. Int #

Helpers

ix1 :: Int -> DIM1 #

Helper for index construction.

Use this instead of explicit constructors like (Z :. (x :: Int)) The this is sometimes needed to ensure that x is constrained to be in Int.

ix2 :: Int -> Int -> DIM2 #

ix3 :: Int -> Int -> Int -> DIM3 #

ix4 :: Int -> Int -> Int -> Int -> DIM4 #

ix5 :: Int -> Int -> Int -> Int -> Int -> DIM5 #

ix6 :: Int -> Int -> Int -> Int -> Int -> Int -> DIM6 #

ix7 :: Int -> Int -> Int -> Int -> Int -> Int -> Int -> DIM7 #

ix8 :: Int -> Int -> Int -> Int -> Int -> Int -> Int -> Int -> DIM8 #

ix9 :: Int -> Int -> Int -> Int -> Int -> Int -> Int -> Int -> Int -> DIM9 #