[Haskell-cafe] Pixel by pixel image processing

Geraldus heraldhoi at gmail.com
Wed Jun 3 10:00:54 UTC 2015


Thank you everybody!
*JuicyPixels* was the first package I have thought about, but I've mistaken
about its functionality and didn't mentioned it here.

*Sylvain*, thank you a lot! You've made my day!

ср, 3 июня 2015 г. в 14:52, Sylvain Henry <hsyl20 at gmail.com>:

> Hi,
>
> Here is a solution using JuicyPixels:
>
> import Codec.Picture
> import Codec.Picture.Types
>
>
> main :: IO ()
> main = do
>    Right img <- readImage "test.png"
>    _ <- writeDynamicPng "test2.png" (dynamicPixelMap circleImage img)
>    return ()
>
> circleImage :: Pixel a => Image a -> Image a
> circleImage img = generateImage (\x y -> f x y $ pixelAt img x y) edge edge
>    where
>       edge = min (imageWidth img) (imageHeight img)
>       f x y a = if x'*x' + y'*y' < e'*e'
>             then a
>             else colorMap (const 0) a
>          where
>             e' = edge `div` 2
>             x' = x - e'
>             y' = y - e'
>
> Sylvain
>
> 2015-06-03 9:19 GMT+02:00 Geraldus <heraldhoi at gmail.com>:
>
>> Hi cafe!
>>
>> I want to do some trivial masking manipulation on PNG images: take a
>> picture, crop it to square shape and then make a circular mask, i.e. take
>> all pixels that lies outside circle with radius equal to half of image
>> width and placed at image center and replace that pixels with zero opacity
>> once (hope this description is clear enough).
>>
>> I've found two packages for image processing so far: `friday` [1] and
>> `unm-hip` [2], but can't figure out which of them suits my needs, maybe
>> there are some other packages I miss?
>>
>> [1] https://hackage.haskell.org/package/friday
>> [2] https://hackage.haskell.org/package/unm-hip
>>
>> _______________________________________________
>> Haskell-Cafe mailing list
>> Haskell-Cafe at haskell.org
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20150603/cd723a8b/attachment.html>


More information about the Haskell-Cafe mailing list