friday-0.1.3: A functionnal image processing library for Haskell.

Safe HaskellSafe-Inferred

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 whereSource

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

Methods

shapeRank :: sh -> IntSource

Gets the number of dimensions in a shape.

shapeLength :: sh -> IntSource

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

shapeZero :: shSource

Gives the first index of an array.

shapeSuccSource

Arguments

:: sh

Shape of the array.

-> sh

Index.

-> sh 

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

toLinearIndexSource

Arguments

:: sh

Shape of the array.

-> sh

Index into the array.

-> Int 

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

fromLinearIndexSource

Arguments

:: sh

Shape of the array.

-> Int

Index into linear representation.

-> sh 

Inverse of toLinearIndex.

shapeList :: sh -> [sh]Source

Return the ascending list of indexes for the given shape.

inShapeSource

Arguments

:: sh

Shape of the array.

-> sh

Index to check for.

-> Bool 

Check whether an index is within a given shape.

Instances

Shape Z 
Shape sh => Shape (:. sh Int) 

data Z Source

An index of dimension zero.

Constructors

Z 

data tail :. head Source

Our index type, used for both shapes and indices.

Constructors

!tail :. !head 

Instances

(Eq tail, Eq head) => Eq (:. tail head) 
(Ord tail, Ord head) => Ord (:. tail head) 
(Read tail, Read head) => Read (:. tail head) 
(Show tail, Show head) => Show (:. tail head) 
Storable sh => Storable (:. sh Int) 
Shape sh => Shape (:. sh Int) 
HistogramShape sh => HistogramShape (:. sh Int) 

Common dimensions.

type DIM0 = ZSource

Helpers

ix1 :: Int -> DIM1Source

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.

ix3 :: Int -> Int -> Int -> DIM3Source

ix4 :: Int -> Int -> Int -> Int -> DIM4Source

ix5 :: Int -> Int -> Int -> Int -> Int -> DIM5Source

ix6 :: Int -> Int -> Int -> Int -> Int -> Int -> DIM6Source

ix7 :: Int -> Int -> Int -> Int -> Int -> Int -> Int -> DIM7Source

ix8 :: Int -> Int -> Int -> Int -> Int -> Int -> Int -> Int -> DIM8Source

ix9 :: Int -> Int -> Int -> Int -> Int -> Int -> Int -> Int -> Int -> DIM9Source