Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Branch: master
Fetching contributors…

Cannot retrieve contributors at this time

27 lines (20 sloc) 0.782 kB
{-# LANGUAGE RankNTypes,TypeOperators #-}
module Image2Buffer where
import Codec.Picture
import Codec.Picture.Types
import Data.Vector.Storable (map,toList)
import Data.List
type Buffer = [[Bool]]
toBuffer :: LumaPlaneExtractable a => Image a -> Buffer
toBuffer img =
let luma = extractLumaPlane img
lumaData = imageData luma
width = imageWidth luma
in chunk width $ toList $ Data.Vector.Storable.map ((<) 128) lumaData
chunk :: Int -> [e] -> [[e]]
chunk i ls =
let splitter [] _ n = n
splitter l c n = l `c` splitter (drop i l) c n
in Data.List.map (take i) (build (splitter ls))
build :: (forall b. (a -> b -> b) -> b -> b) -> [a]
build g = g (:) []
Jump to Line
Something went wrong with that request. Please try again.