[Haskell-cafe] fast image processing in haskell?
Jeff Briggs
ephemeral.elusive at gmail.com
Sun Aug 6 06:53:08 EDT 2006
On 06/08/06, Bulat Ziganshin <bulat.ziganshin at gmail.com> wrote:
> more used than average lib. btw, is it possible to rewrite this
> algorithm in more high-level way using FPS, of course with more or
> less good speed?
Using Data.ByteString, I see no noticeable decrease in performance.
data C = R|G|B deriving Show
...
B.useAsCStringLen image $ \ (src,len) ->
copyBytes dst (castPtr src) len
print $ B.foldl sum_rgb (0,0,0,R) image
...
sum_rgb (r,g,b,s) px
= r `seq` g `seq` b `seq` case s of
R -> (r+px, g, b, G)
G -> (r, g+px, b, B)
_ -> (r, g, b+px, R)
Fantastic library.
More information about the Haskell-Cafe
mailing list