CV-0.3.5.3: OpenCV based machine vision library

Safe HaskellSafe-Infered

CV.Image

Contents

Synopsis

Basic types

empty :: CreateImage (Image a b) => (Int, Int) -> Image a b

Allocate a new empty image

emptyCopy :: CreateImage (Image a b) => Image a b -> Image a b

 Allocate a new image that of the same size and type as the exemplar image given.

cloneImage :: Image a b -> IO (Image a b)

Create a copy of an image

withClone :: Image channels depth -> (Image channels depth -> IO ()) -> IO (Image channels depth)

withCloneValue :: Image channels depth -> (Image channels depth -> IO a) -> IO a

Colour spaces

type family ChannelOf a :: *

Type family for expressing which channels a colorspace contains. This needs to be fixed wrt. the BGR color space.

type D32 = Float

type D64 = Double

type D8 = Word8

data Tag tp

compose :: Composes a => Source a -> a

IO operations

class Loadable a where

Typeclass for CV items that can be read from file. Mainly images at this point.

Methods

readFromFile :: FilePath -> IO a

saveImage :: FilePath -> Image c d -> IO ()

Save image. This will convert the image to 8 bit one before saving

Pixel level access

class GetPixel a where

Associated Types

type P a :: *

Methods

getPixel :: (Int, Int) -> a -> P a

class SetPixel a where

Associated Types

type SP a :: *

Methods

setPixel :: (Int, Int) -> SP a -> a -> IO ()

getAllPixels :: (GetPixel a, Sized a, ~ * (Size a) (Int, Int)) => a -> [P a]

getAllPixelsRowMajor :: (GetPixel a, Sized a, ~ * (Size a) (Int, Int)) => a -> [P a]

mapImageInplace :: (P (Image GrayScale D32) -> P (Image GrayScale D32)) -> Image GrayScale D32 -> IO ()

Perform (a destructive) inplace map of the image. This should be wrapped inside withClone or an image operation

Image information

class Sized a where

Typeclass for elements with a size, such as images and matrices.

Associated Types

type Size a :: *

Methods

getSize :: a -> Size a

getArea :: (Sized a, Num b, Size a ~ (b, b)) => a -> b

getChannel :: Enum a => a -> Image (ChannelOf a) d -> Image GrayScale d

ROI's, COI's and subregions

setCOI :: Integral a => a -> Image c d -> IO ()

setROI :: (Integral t3, Integral t2, Integral t1, Integral t) => (t, t1) -> (t2, t3) -> Image c d -> IO ()

resetROI :: Image c d -> IO ()

getRegion :: (Int, Int) -> (Int, Int) -> Image c d -> Image c d

withIOROI :: (Integral t, Integral t1, Integral t2, Integral t3) => (t, t1) -> (t2, t3) -> Image c d -> IO b -> IO b

withROI :: (Int, Int) -> (Int, Int) -> Image c d -> (Image c d -> a) -> a

Blitting

blendBlit :: Image c d -> Image c1 d1 -> Image c3 d3 -> Image c2 d2 -> (CInt, CInt) -> IO ()

Blit image2 onto image1. This uses an alpha channel bitmap for determining the regions where the image should be blended with the base image.

blitM :: (Integral a3, Integral a2, Integral a1, Integral a) => (a, a1) -> [((a2, a3), Image GrayScale D32)] -> Image GrayScale D32

subPixelBlit :: Image c d -> Image c d -> (CDouble, CDouble) -> IO ()

montage :: CreateImage (Image GrayScale D32) => (Int, Int) -> Int -> [Image GrayScale D32] -> Image GrayScale D32

Create a montage form given images (u,v) determines the layout and space the spacing between images. Images are assumed to be the same size (determined by the first image)

tileImages :: Image c d -> Image c1 d1 -> (CInt, CInt) -> Image channels depth

Tile images by overlapping them on a black canvas.

Conversions

bgrToRgb :: Image BGR depth -> Image RGB depth

rgbToBgr :: Image BGR depth -> Image RGB depth

unsafeImageTo8Bit :: Image cspace a -> Image cspace D8

Low level access operations

newtype BareImage

Instances

creatingImage :: IO (Ptr BareImage) -> IO (Image channels depth)

unS :: Image t t1 -> BareImage

 Remove typing info from an image

withGenBareImage :: BareImage -> (Ptr b -> IO b1) -> IO b1

withGenImage :: Image c d -> (Ptr b -> IO a) -> IO a

withImage :: Image c d -> (Ptr BareImage -> IO a) -> IO a

Extended error handling