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

Safe HaskellSafe-Inferred
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 Source

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

Methods

shapeRank :: sh -> Int Source

Gets the number of dimensions in a shape.

shapeLength :: sh -> Int Source

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

shapeZero :: sh Source

Gives the first index of an array.

shapeSucc Source

Arguments

:: sh

Shape of the array.

-> sh

Index.

-> sh 

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

toLinearIndex Source

Arguments

:: sh

Shape of the array.

-> sh

Index into the array.

-> Int 

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

fromLinearIndex Source

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.

inShape Source

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 infixl 3 Source

Our index type, used for both shapes and indices.

Constructors

!tail :. !head infixl 3 

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 = Z Source

Helpers

ix1 :: Int -> DIM1 Source

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 Source

ix3 :: Int -> Int -> Int -> DIM3 Source

ix4 :: Int -> Int -> Int -> Int -> DIM4 Source

ix5 :: Int -> Int -> Int -> Int -> Int -> DIM5 Source

ix6 :: Int -> Int -> Int -> Int -> Int -> Int -> DIM6 Source

ix7 :: Int -> Int -> Int -> Int -> Int -> Int -> Int -> DIM7 Source

ix8 :: Int -> Int -> Int -> Int -> Int -> Int -> Int -> Int -> DIM8 Source

ix9 :: Int -> Int -> Int -> Int -> Int -> Int -> Int -> Int -> Int -> DIM9 Source