fix: export Picture
This commit is contained in:
parent
2403c2fd6e
commit
bc02da7242
@ -3,15 +3,16 @@
|
|||||||
{-# LANGUAGE TypeFamilies #-}
|
{-# LANGUAGE TypeFamilies #-}
|
||||||
|
|
||||||
{-|
|
{-|
|
||||||
Module : Picture
|
Module : Data.Picture
|
||||||
Description : manipulation functions
|
Description : picture manipulation functions
|
||||||
Copyright : (c) Mahdi Dibaiee, 2016
|
Copyright : (c) Mahdi Dibaiee, 2016
|
||||||
License : GPL-3
|
License : GPL-3
|
||||||
Maintainer : mdibaiee@aol.com
|
Maintainer : mdibaiee@aol.com
|
||||||
Stability : experimental
|
Stability : experimental
|
||||||
Portability : POSIX
|
Portability : POSIX
|
||||||
-}
|
-}
|
||||||
module Data.Picture ( grayscale
|
module Data.Picture ( Picture
|
||||||
|
, grayscale
|
||||||
, readPicture
|
, readPicture
|
||||||
, fromImage
|
, fromImage
|
||||||
, toImage
|
, toImage
|
||||||
@ -31,10 +32,10 @@ module Data.Picture ( grayscale
|
|||||||
import System.IO
|
import System.IO
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
|
|
||||||
-- | 'Picture' type is just a triple of color channel matrices: (R, G, B)
|
-- | (R, G, B) color channels
|
||||||
type Picture = (Matrix Double, Matrix Double, Matrix Double)
|
type Picture = (Matrix Double, Matrix Double, Matrix Double)
|
||||||
|
|
||||||
-- |Converts a JuicyPixel 'Image PixelRGB8' to 'Picture'
|
-- | Converts a JuicyPixel 'Image PixelRGB8' to 'Picture'
|
||||||
fromImage :: Image PixelRGB8 -> Picture
|
fromImage :: Image PixelRGB8 -> Picture
|
||||||
fromImage Image { imageWidth = w, imageHeight = h, imageData = vec } =
|
fromImage Image { imageWidth = w, imageHeight = h, imageData = vec } =
|
||||||
let [r, g, b] = map (reshape w . V.fromList . reverse) (snd $ V.foldl' gp (0, [[],[],[]]) (V.map fromIntegral vec))
|
let [r, g, b] = map (reshape w . V.fromList . reverse) (snd $ V.foldl' gp (0, [[],[],[]]) (V.map fromIntegral vec))
|
||||||
@ -46,7 +47,7 @@ module Data.Picture ( grayscale
|
|||||||
(1, [r, g, b]) -> (2, [r, x:g, b])
|
(1, [r, g, b]) -> (2, [r, x:g, b])
|
||||||
(2, [r, g, b]) -> (0, [r, g, x:b])
|
(2, [r, g, b]) -> (0, [r, g, x:b])
|
||||||
|
|
||||||
-- |Converts a 'Picture' to JuicyPixel 'Image PixelRGB8'
|
-- | Converts a 'Picture' to JuicyPixel 'Image PixelRGB8'
|
||||||
toImage :: Picture -> Image PixelRGB8
|
toImage :: Picture -> Image PixelRGB8
|
||||||
toImage (r, g, b) =
|
toImage (r, g, b) =
|
||||||
let (fr, fg, fb) = (toList $ flatten r, toList $ flatten g, toList $ flatten b)
|
let (fr, fg, fb) = (toList $ flatten r, toList $ flatten g, toList $ flatten b)
|
||||||
|
Loading…
Reference in New Issue
Block a user