{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE ViewPatterns #-}
module Graphics.Image.Processing (
module Graphics.Image.Processing.Geometric,
module Graphics.Image.Processing.Interpolation,
module Graphics.Image.Processing.Convolution,
module Graphics.Image.Processing.Filter,
Border(..), pixelGrid
) where
#if MIN_VERSION_base(4,8,0)
import Prelude hiding (traverse)
#endif
import Data.Word (Word8)
import Graphics.Image.Interface
import Graphics.Image.Processing.Convolution
import Graphics.Image.Processing.Geometric
import Graphics.Image.Processing.Interpolation
import Graphics.Image.Processing.Filter
pixelGrid :: Array arr cs e =>
Word8
-> Image arr cs e
-> Image arr cs e
pixelGrid !(succ . fromIntegral -> k) !img = traverse img getNewDims getNewPx where
getNewDims !(m, n) = (1 + m*k, 1 + n*k)
{-# INLINE getNewDims #-}
getNewPx !getPx !(i, j) = if i `mod` k == 0 || j `mod` k == 0
then promote $ fromDouble 0.5
else getPx ((i - 1) `div` k, (j - 1) `div` k)
{-# INLINE getNewPx #-}
{-# INLINE pixelGrid #-}