Safe Haskell | None |
---|---|
Language | Haskell2010 |
A thin JuicyPixels layer.
- type Mat2D h w channels depth = Mat (S '[h, w]) channels depth
- type Filter m h w c d = Mat2D h w c d -> CvExceptT m (Mat2D h w c d)
- type family PixelChannels a :: Nat
- type family PixelDepth a
- fromImage :: forall a c d. (ToDepth (Proxy d), KnownNat c, Pixel a, Storable a, c ~ PixelChannels a, d ~ PixelDepth a) => Image a -> Mat2D D D (S c) (S d)
- toImage :: forall a c d h w. (KnownNat c, Pixel a, Storable a, c ~ PixelChannels a, d ~ PixelDepth a) => Mat2D h w (S c) (S d) -> Image a
- isoJuicy :: forall m. PrimMonad m => (forall c d h w. Filter m h w c d) -> DynamicImage -> CvExceptT m DynamicImage
Types
type Mat2D h w channels depth = Mat (S '[h, w]) channels depth Source #
An OpenCV bidimensional matrix
type Filter m h w c d = Mat2D h w c d -> CvExceptT m (Mat2D h w c d) Source #
An OpenCV 2D-filter preserving the matrix type
type family PixelChannels a :: Nat Source #
map Pixel types to a number of channels
type PixelChannels Pixel8 Source # | |
type PixelChannels Pixel16 Source # | |
type PixelChannels PixelF Source # | |
type PixelChannels PixelYA8 Source # | |
type PixelChannels PixelYA16 Source # | |
type PixelChannels PixelRGB8 Source # | |
type PixelChannels PixelRGB16 Source # | |
type PixelChannels PixelRGBF Source # | |
type PixelChannels PixelYCbCr8 Source # | |
type PixelChannels PixelCMYK8 Source # | |
type PixelChannels PixelCMYK16 Source # | |
type PixelChannels PixelRGBA8 Source # | |
type PixelChannels PixelRGBA16 Source # | |
type family PixelDepth a Source #
map Pixel types to a depth
type PixelDepth Pixel8 Source # | |
type PixelDepth Pixel16 Source # | |
type PixelDepth PixelF Source # | |
type PixelDepth PixelYA8 Source # | |
type PixelDepth PixelYA16 Source # | |
type PixelDepth PixelRGB8 Source # | |
type PixelDepth PixelRGB16 Source # | |
type PixelDepth PixelRGBF Source # | |
type PixelDepth PixelYCbCr8 Source # | |
type PixelDepth PixelCMYK8 Source # | |
type PixelDepth PixelCMYK16 Source # | |
type PixelDepth PixelRGBA8 Source # | |
type PixelDepth PixelRGBA16 Source # | |
Low level API
:: (ToDepth (Proxy d), KnownNat c, Pixel a, Storable a, c ~ PixelChannels a, d ~ PixelDepth a) | |
=> Image a | JuicyPixels image |
-> Mat2D D D (S c) (S d) |
Compute an OpenCV 2D-matrix from a JuicyPixels image.
Example:
fromImageImg :: IO (Mat ('S '[ 'D, 'D]) ('S 3) ('S Word8)) fromImageImg = do r <- Codec.Picture.readImage "data/Lenna.png" case r of Left err -> error err Right (Codec.Picture.ImageRGB8 img) -> pure $ OpenCV.Juicy.fromImage img Right _ -> error "Unhandled JuicyPixels format!"
:: (KnownNat c, Pixel a, Storable a, c ~ PixelChannels a, d ~ PixelDepth a) | |
=> Mat2D h w (S c) (S d) | OpenCV 2D-matrix |
-> Image a |
Compute a JuicyPixels image from an OpenCV 2D-matrix
FIXME: There's a bug in the colour conversions in the example:
Example:
toImageImg :: IO (Mat ('S '[ 'D, 'D]) ('S 3) ('S Word8)) toImageImg = exceptError . cvtColor rgb bgr . from . to . exceptError . cvtColor bgr rgb <$> fromImageImg where to :: OpenCV.Juicy.Mat2D 'D 'D ('S 3) ('S Word8) -> Codec.Picture.Image Codec.Picture.PixelRGB8 to = OpenCV.Juicy.toImage from :: Codec.Picture.Image Codec.Picture.PixelRGB8 -> OpenCV.Juicy.Mat2D 'D 'D ('S 3) ('S Word8) from = OpenCV.Juicy.fromImage
High level API
:: PrimMonad m | |
=> (forall c d h w. Filter m h w c d) | OpenCV 2D-filter |
-> DynamicImage | JuicyPixels dynamic image |
-> CvExceptT m DynamicImage |
Apply an OpenCV 2D-filter to a JuicyPixels dynamic matrix, preserving the Juicy pixel encoding