packages feed

JuicyPixels-repa 0.6 → 0.6.1

raw patch · 2 files changed

+32/−15 lines, 2 filesdep ~basePVP ok

version bump matches the API change (PVP)

Dependency ranges changed: base

API changes (from Hackage documentation)

Files

Codec/Picture/Repa.hs view
@@ -20,6 +20,7 @@        , ToRGBAChannels(..)        ) where import qualified Data.Array.Repa as R+import qualified Data.Array.Repa.Unsafe as RU import qualified Data.Array.Repa.Repr.ForeignPtr as RF import Data.Array.Repa.Repr.ForeignPtr (F) import Data.Array.Repa ((:.), Array, (:.)(..), Z(..), DIM3, backpermute, extent)@@ -154,20 +155,20 @@  instance Collapsable RGBA (Word8,Word8,Word8,Word8) where     collapseColorChannel (Img a) =-        R.traverse4 a a a a-             (\_ _ _ (Z:.r:.c:._) -> Z:.r:.c)-             (\l1 l2 l3 l4 idx -> (l1 (idx:.0)-                               ,l2 (idx:.1)-                               ,l3 (idx:.2)-                               ,l4 (idx:.3)))+        R.traverse a+             (\(Z:.r:.c:._) -> Z:.r:.c)+             (\l idx -> (l (idx:.0)+                        ,l (idx:.1)+                        ,l (idx:.2)+                        ,l (idx:.3)))  instance Collapsable RGBA (Word8,Word8,Word8) where     collapseColorChannel (Img a) =-        R.traverse3 a a a-             (\_ _ (Z:.r:.c:._) -> Z:.r:.c)-             (\l1 l2 l3 idx -> (l1 (idx:.0)-                               ,l2 (idx:.1)-                               ,l3 (idx:.2)))+        R.traverse a+             (\(Z:.r:.c:._) -> Z:.r:.c)+             (\l idx -> (l (idx:.0)+                        ,l (idx:.1)+                        ,l (idx:.2)))  -- Helper functions -- getChannel :: Int -> PixelRGBA8 -> Word8@@ -307,7 +308,7 @@   (Z :. ha :. _ :. _) = R.extent a   (Z :. hb :. _ :. _) = R.extent b   stack fa fb (Z :. h :. w :. d)-	| h < hb    = fb (Z :. h :. w :. d)+        | h < hb    = fb (Z :. h :. w :. d)         | otherwise = fa (Z :. h - hb :. w :. d)  vConcat :: [Array F DIM3 Word8] -> Array F DIM3 Word8@@ -326,5 +327,21 @@     = Z :. min r1 r2 :. c1 + c2 :. min d1 d2   (Z :. _ :. ca :. _) = R.extent a   stack fa fb (Z :. r :. c :. d)-	| c < ca    = fa (Z :. r :. c :. d)-	| otherwise = fb (Z :. r :. c - ca :. d)+        | c < ca    = fa (Z :. r :. c :. d)+        | otherwise = fb (Z :. r :. c - ca :. d)++type Histogram = R.Array R.D R.DIM1 Word8++histograms :: Img a -> (Histogram, Histogram, Histogram, Histogram)+histograms (Img arr) =+    let (Z:.nrRow:.nrCol:._) = R.extent arr+        zero = R.fromFunction (Z:.256) (\_ -> 0 :: Word8)+        incElem idx x = RU.unsafeTraverse x id (\l i -> l i + if i==(Z:.fromIntegral idx) then 1 else 0)+    in Prelude.foldl (\(hR, hG, hB, hA) (row,col) ->+             let r = R.unsafeIndex arr (Z:.row:.col:.0)+                 g = R.unsafeIndex arr (Z:.row:.col:.1)+                 b = R.unsafeIndex arr (Z:.row:.col:.2)+                 a = R.unsafeIndex arr (Z:.row:.col:.3)+             in (incElem r hR, incElem g hG, incElem b hB, incElem a hA))+          (zero,zero,zero,zero)+          [ (row,col) | row <- [0..nrRow-1], col <- [0..nrCol-1] ]
JuicyPixels-repa.cabal view
@@ -1,5 +1,5 @@ Name:                JuicyPixels-repa-Version:             0.6+Version:             0.6.1 Synopsis:            Convenience functions to obtain array representations of images. Description:         This wraps the Juicy.Pixels library to convert into 'Repa' and                       'Data.Vector.Storable' formats.