-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Haskell Image Processing (HIP) Library. -- -- Haskell Image Processing (HIP) Library provides an easy to use -- interface with a whole variaty of image manipulation capabilities. -- -- Processing can be done sequentially as well as in parallel, with an -- inherited fusion capabily, all through repa and vector -- packages. It is highly extendable, with an ability to add various -- color spaces or provide implementations for underlying array like -- custom data structures. -- -- It is capable of reading and writing a number of popular image formats -- by using JuciyPixels and netpbm packages. Being a pure -- Haskell library it does not require any external programs, although it -- can display images using a program of your choice. @package hip @version 1.5.2.0 module Graphics.Image.Interface -- | A Pixel family with a color space and a precision of elements. class (Eq cs, Enum cs, Show cs, Bounded cs, Typeable cs, Elevator e, Eq (Pixel cs e), Unbox (Components cs e)) => ColorSpace cs e where type Components cs e foldrPx f !z0 !xs = foldlPx f' id xs z0 where f' k x !z = k $! f x z foldlPx f !z0 !xs = foldrPx f' id xs z0 where f' x k !z = k $! f z x foldl1Px f !xs = fromMaybe (error "foldl1Px: empty Pixel") (foldlPx mf Nothing xs) where mf m !y = Just (case m of { Nothing -> y Just x -> f x y }) toListPx !px = foldr' f [] (enumFrom (toEnum 0)) where f !cs !ls = getPxC px cs : ls where { type family Components cs e; } -- | Convert a Pixel to a representation suitable for storage as an unboxed -- element, usually a tuple of channels. toComponents :: ColorSpace cs e => Pixel cs e -> Components cs e -- | Convert from an elemnt representation back to a Pixel. fromComponents :: ColorSpace cs e => Components cs e -> Pixel cs e -- | Construt a Pixel by replicating the same value across all of the -- components. promote :: ColorSpace cs e => e -> Pixel cs e -- | Retrieve Pixel's component value getPxC :: ColorSpace cs e => Pixel cs e -> cs -> e -- | Set Pixel's component value setPxC :: ColorSpace cs e => Pixel cs e -> cs -> e -> Pixel cs e -- | Map a channel aware function over all Pixel's components. mapPxC :: ColorSpace cs e => (cs -> e -> e) -> Pixel cs e -> Pixel cs e -- | Map a function over all Pixel's componenets. liftPx :: ColorSpace cs e => (e -> e) -> Pixel cs e -> Pixel cs e -- | Zip two Pixels with a function. liftPx2 :: ColorSpace cs e => (e -> e -> e) -> Pixel cs e -> Pixel cs e -> Pixel cs e foldlPx2 :: ColorSpace cs e => (b -> e -> e -> b) -> b -> Pixel cs e -> Pixel cs e -> b -- | Right fold over all Pixel's components. foldrPx :: ColorSpace cs e => (e -> b -> b) -> b -> Pixel cs e -> b -- | Left strict fold over all Pixel's components. foldlPx :: ColorSpace cs e => (b -> e -> b) -> b -> Pixel cs e -> b foldl1Px :: ColorSpace cs e => (e -> e -> e) -> Pixel cs e -> e toListPx :: ColorSpace cs e => Pixel cs e -> [e] -- | A color space that supports transparency. class (ColorSpace (Opaque cs) e, ColorSpace cs e) => AlphaSpace cs e where type Opaque cs where { type family Opaque cs; } -- | Get an alpha channel of a transparant pixel. getAlpha :: AlphaSpace cs e => Pixel cs e -> e -- | Add an alpha channel to an opaque pixel. -- --
--   addAlpha 0 (PixelHSI 1 2 3) == PixelHSIA 1 2 3 0
--   
addAlpha :: AlphaSpace cs e => e -> Pixel (Opaque cs) e -> Pixel cs e -- | Convert a transparent pixel to an opaque one by dropping the alpha -- channel. -- --
--   dropAlpha (PixelRGBA 1 2 3 4) == PixelRGB 1 2 3
--   
dropAlpha :: AlphaSpace cs e => Pixel cs e -> Pixel (Opaque cs) e -- | A class with a set of convenient functions that allow for changing -- precision of channels within pixels, while scaling the values to keep -- them in an appropriate range. -- --
--   >>> let rgb = PixelRGB 0.0 0.5 1.0 :: Pixel RGB Double
--   
--   >>> toWord8 <$> rgb
--   <RGB:(0|128|255)>
--   
--   >>> toWord16 <$> rgb
--   <RGB:(0|32768|65535)>
--   
class (Eq e, Num e, Typeable e, Unbox e) => Elevator e -- | Values are scaled to [0, 255] range. toWord8 :: Elevator e => e -> Word8 -- | Values are scaled to [0, 65535] range. toWord16 :: Elevator e => e -> Word16 -- | Values are scaled to [0, 4294967295] range. toWord32 :: Elevator e => e -> Word32 -- | Values are scaled to [0, 18446744073709551615] range. toWord64 :: Elevator e => e -> Word64 -- | Values are scaled to [0.0, 1.0] range. toFloat :: Elevator e => e -> Float -- | Values are scaled to [0.0, 1.0] range. toDouble :: Elevator e => e -> Double -- | Values are scaled from [0.0, 1.0] range. fromDouble :: Elevator e => Double -> e -- | Base array like representation for an image. class (Typeable arr, ColorSpace cs e, SuperClass arr cs e) => BaseArray arr cs e where type SuperClass arr cs e :: Constraint data Image arr cs e where { type family SuperClass arr cs e :: Constraint; data family Image arr cs e; } -- | Get dimensions of an image. -- --
--   >>> frog <- readImageRGB VU "images/frog.jpg"
--   
--   >>> frog
--   <Image VectorUnboxed RGB (Double): 200x320>
--   
--   >>> dims frog
--   (200,320)
--   
dims :: BaseArray arr cs e => Image arr cs e -> (Int, Int) class (Vector (Vector arr) (Pixel cs e), MArray (Manifest arr) cs e, BaseArray arr cs e) => Array arr cs e where type Manifest arr :: * type Vector arr :: * -> * where { type family Manifest arr :: *; type family Vector arr :: * -> *; } -- | Create an Image by supplying it's dimensions and a pixel generating -- function. makeImage :: Array arr cs e => (Int, Int) -> ((Int, Int) -> Pixel cs e) -> Image arr cs e makeImageWindowed :: Array arr cs e => (Int, Int) -> ((Int, Int), (Int, Int)) -> ((Int, Int) -> Pixel cs e) -> ((Int, Int) -> Pixel cs e) -> Image arr cs e -- | Create a scalar image, required for various operations on images with -- a scalar. scalar :: Array arr cs e => Pixel cs e -> Image arr cs e -- | Retrieves a pixel at (0, 0) index. Useful together with -- fold, when arbitrary initial pixel is needed. index00 :: Array arr cs e => Image arr cs e -> Pixel cs e -- | Map a function over a an image. map :: (Array arr cs e, Array arr cs' e') => (Pixel cs' e' -> Pixel cs e) -> Image arr cs' e' -> Image arr cs e -- | Map an index aware function over each pixel in an image. imap :: (Array arr cs e, Array arr cs' e') => ((Int, Int) -> Pixel cs' e' -> Pixel cs e) -> Image arr cs' e' -> Image arr cs e -- | Zip two images with a function zipWith :: (Array arr cs e, Array arr cs1 e1, Array arr cs2 e2) => (Pixel cs1 e1 -> Pixel cs2 e2 -> Pixel cs e) -> Image arr cs1 e1 -> Image arr cs2 e2 -> Image arr cs e -- | Zip two images with an index aware function izipWith :: (Array arr cs e, Array arr cs1 e1, Array arr cs2 e2) => ((Int, Int) -> Pixel cs1 e1 -> Pixel cs2 e2 -> Pixel cs e) -> Image arr cs1 e1 -> Image arr cs2 e2 -> Image arr cs e -- | Traverse an image traverse :: (Array arr cs e, Array arr cs' e') => Image arr cs' e' -> ((Int, Int) -> (Int, Int)) -> (((Int, Int) -> Pixel cs' e') -> (Int, Int) -> Pixel cs e) -> Image arr cs e -- | Traverse two images. traverse2 :: (Array arr cs e, Array arr cs1 e1, Array arr cs2 e2) => Image arr cs1 e1 -> Image arr cs2 e2 -> ((Int, Int) -> (Int, Int) -> (Int, Int)) -> (((Int, Int) -> Pixel cs1 e1) -> ((Int, Int) -> Pixel cs2 e2) -> (Int, Int) -> Pixel cs e) -> Image arr cs e -- | Transpose an image transpose :: Array arr cs e => Image arr cs e -> Image arr cs e -- | Backwards permutation of an image. backpermute :: Array arr cs e => (Int, Int) -> ((Int, Int) -> (Int, Int)) -> Image arr cs e -> Image arr cs e -- | Construct an image from a nested rectangular shaped list of pixels. -- Length of an outer list will constitute m rows, while the -- length of inner lists - n columns. All of the inner lists -- must be the same length and greater than 0. -- --
--   >>> fromLists [[PixelY (fromIntegral (i*j) / 60000) | j <- [1..300]] | i <- [1..200]]
--   <Image VectorUnboxed Y (Double): 200x300>
--   
-- fromLists :: Array arr cs e => [[Pixel cs e]] -> Image arr cs e -- | Perform matrix multiplication on two images. Inner dimensions must -- agree. (|*|) :: Array arr cs e => Image arr cs e -> Image arr cs e -> Image arr cs e -- | Undirected reduction of an image. fold :: Array arr cs e => (Pixel cs e -> Pixel cs e -> Pixel cs e) -> Pixel cs e -> Image arr cs e -> Pixel cs e -- | Undirected reduction of an image with an index aware function. foldIx :: Array arr cs e => (Pixel cs e -> (Int, Int) -> Pixel cs e -> Pixel cs e) -> Pixel cs e -> Image arr cs e -> Pixel cs e -- | Pixelwise equality function of two images. Images are considered -- distinct if either images' dimensions or at least one pair of -- corresponding pixels are not the same. Used in defining an in instance -- for the Eq typeclass. eq :: (Array arr cs e, Eq (Pixel cs e)) => Image arr cs e -> Image arr cs e -> Bool -- | Array class does not enforce an image to be represented as -- concrete array of pixels in memory, but if at any time it is desired -- for the image to be brought to a computed state, this function can be -- used. compute :: Array arr cs e => Image arr cs e -> Image arr cs e -- | Each array has a sibling Manifest array representation, which toManifest :: Array arr cs e => Image arr cs e -> Image (Manifest arr) cs e -- | Convert an image to a flattened Vector. For all current -- representations it is a O(1) opeartion. -- --
--   >>> toVector $ makeImage (3, 2) (\(i, j) -> PixelY $ fromIntegral (i+j))
--   fromList [<Luma:(0.0)>,<Luma:(1.0)>,<Luma:(1.0)>,<Luma:(2.0)>,<Luma:(2.0)>,<Luma:(3.0)>]
--   
toVector :: Array arr cs e => Image arr cs e -> Vector arr (Pixel cs e) -- | Construct a two dimensional image with m rows and n -- columns from a flat Vector of length k. For all -- current representations it is a O(1) opeartion. Make sure that -- m * n = k. -- --
--   >>> fromVector (200, 300) $ generate 60000 (\i -> PixelY $ fromIntegral i / 60000)
--   <Image Vector Luma: 200x300>
--   
-- fromVector :: Array arr cs e => (Int, Int) -> Vector arr (Pixel cs e) -> Image arr cs e -- | Array representation that is actually has real data stored in memory, -- hence allowing for image indexing, forcing pixels into computed state -- etc. class BaseArray arr cs e => MArray arr cs e where data MImage s arr cs e index !img !ix = borderIndex (error $ show img ++ " - Index out of bounds: " ++ show ix) img ix where { data family MImage s arr cs e; } unsafeIndex :: MArray arr cs e => Image arr cs e -> (Int, Int) -> Pixel cs e -- | Get a pixel at i-th and j-th location. -- --
--   >>> let grad_gray = makeImage (200, 200) (\(i, j) -> PixelY $ fromIntegral (i*j)) / (200*200)
--   
--   >>> index grad_gray (20, 30) == PixelY ((20*30) / (200*200))
--   True
--   
index :: MArray arr cs e => Image arr cs e -> (Int, Int) -> Pixel cs e -- | Make sure that an image is fully evaluated. deepSeqImage :: MArray arr cs e => Image arr cs e -> a -> a -- | Fold an image from the left in a row major order. foldl :: MArray arr cs e => (a -> Pixel cs e -> a) -> a -> Image arr cs e -> a -- | Fold an image from the right in a row major order. foldr :: MArray arr cs e => (Pixel cs e -> a -> a) -> a -> Image arr cs e -> a -- | Create an Image by supplying it's dimensions and a monadic pixel -- generating action. makeImageM :: (MArray arr cs e, Functor m, Monad m) => (Int, Int) -> ((Int, Int) -> m (Pixel cs e)) -> m (Image arr cs e) -- | Monading mapping over an image. mapM :: (MArray arr cs e, MArray arr cs' e', Functor m, Monad m) => (Pixel cs' e' -> m (Pixel cs e)) -> Image arr cs' e' -> m (Image arr cs e) -- | Monading mapping over an image. Result is discarded. mapM_ :: (MArray arr cs e, Functor m, Monad m) => (Pixel cs e -> m b) -> Image arr cs e -> m () -- | Monadic folding. foldM :: (MArray arr cs e, Functor m, Monad m) => (a -> Pixel cs e -> m a) -> a -> Image arr cs e -> m a -- | Monadic folding. Result is discarded. foldM_ :: (MArray arr cs e, Functor m, Monad m) => (a -> Pixel cs e -> m a) -> a -> Image arr cs e -> m () -- | Get dimensions of a mutable image. mdims :: MArray arr cs e => MImage s arr cs e -> (Int, Int) -- | Yield a mutable copy of an image. thaw :: (MArray arr cs e, Functor m, PrimMonad m) => Image arr cs e -> m (MImage (PrimState m) arr cs e) -- | Yield an immutable copy of an image. freeze :: (MArray arr cs e, Functor m, PrimMonad m) => MImage (PrimState m) arr cs e -> m (Image arr cs e) -- | Create a mutable image with given dimensions. Pixels are likely -- uninitialized. new :: (MArray arr cs e, Functor m, PrimMonad m) => (Int, Int) -> m (MImage (PrimState m) arr cs e) -- | Yield the pixel at a given location. read :: (MArray arr cs e, Functor m, PrimMonad m) => MImage (PrimState m) arr cs e -> (Int, Int) -> m (Pixel cs e) -- | Set a pixel at a given location. write :: (MArray arr cs e, Functor m, PrimMonad m) => MImage (PrimState m) arr cs e -> (Int, Int) -> Pixel cs e -> m () -- | Swap pixels at given locations. swap :: (MArray arr cs e, Functor m, PrimMonad m) => MImage (PrimState m) arr cs e -> (Int, Int) -> (Int, Int) -> m () -- | Exchange the underlying array representation of an image. exchange :: (Array arr' cs e, Array arr cs e) => arr -> Image arr' cs e -> Image arr cs e -- | Image indexing function that returns a default pixel if index is out -- of bounds. defaultIndex :: MArray arr cs e => Pixel cs e -> Image arr cs e -> (Int, Int) -> Pixel cs e -- | Image indexing function that uses a special border resolutions -- strategy for out of bounds pixels. borderIndex :: MArray arr cs e => Border (Pixel cs e) -> Image arr cs e -> (Int, Int) -> Pixel cs e -- | Image indexing function that returns Nothing if index -- is out of bounds, Just px otherwise. maybeIndex :: MArray arr cs e => Image arr cs e -> (Int, Int) -> Maybe (Pixel cs e) -- | Approach to be used near the borders during various transformations. -- Whenever a function needs information not only about a pixel of -- interest, but also about it's neighbours, it will go out of bounds -- around the image edges, hence is this set of approaches that can be -- used in such situtation. data Border px -- | Fill in a constant pixel. -- --
--              outside |  Image  | outside
--   (Fill 0) : 0 0 0 0 | 1 2 3 4 | 0 0 0 0
--   
Fill :: !px -> Border px -- | Wrap around from the opposite border of the image. -- --
--              outside |  Image  | outside
--   Wrap :     1 2 3 4 | 1 2 3 4 | 1 2 3 4
--   
Wrap :: Border px -- | Replicate the pixel at the edge. -- --
--              outside |  Image  | outside
--   Edge :     1 1 1 1 | 1 2 3 4 | 4 4 4 4
--   
Edge :: Border px -- | Mirror like reflection. -- --
--              outside |  Image  | outside
--   Reflect :  4 3 2 1 | 1 2 3 4 | 4 3 2 1
--   
Reflect :: Border px -- | Also mirror like reflection, but without repeating the edge pixel. -- --
--              outside |  Image  | outside
--   Continue : 1 4 3 2 | 1 2 3 4 | 3 2 1 4
--   
Continue :: Border px -- | Border handling function. If (i, j) location is within -- bounds, then supplied lookup function will be used, otherwise it will -- be handled according to a supplied border strategy. handleBorderIndex :: Border px -> (Int, Int) -> ((Int, Int) -> px) -> (Int, Int) -> px -- | 2D to a flat vector index conversion. -- -- Note: There is an implicit assumption that j < n fromIx :: Int -> (Int, Int) -> Int -- | Flat vector to 2D index conversion. toIx :: Int -> Int -> (Int, Int) checkDims :: String -> (Int, Int) -> (Int, Int) instance GHC.Show.Show px => GHC.Show.Show (Graphics.Image.Interface.Border px) instance (Graphics.Image.Interface.ColorSpace cs e, GHC.Num.Num e) => GHC.Num.Num (Graphics.Image.Interface.Pixel cs e) instance (Graphics.Image.Interface.ColorSpace cs e, GHC.Real.Fractional e) => GHC.Real.Fractional (Graphics.Image.Interface.Pixel cs e) instance (Graphics.Image.Interface.ColorSpace cs e, GHC.Float.Floating e) => GHC.Float.Floating (Graphics.Image.Interface.Pixel cs e) instance (Graphics.Image.Interface.ColorSpace cs e, GHC.Enum.Bounded e) => GHC.Enum.Bounded (Graphics.Image.Interface.Pixel cs e) instance (Data.Foldable.Foldable (Graphics.Image.Interface.Pixel cs), Control.DeepSeq.NFData e) => Control.DeepSeq.NFData (Graphics.Image.Interface.Pixel cs e) instance (Graphics.Image.Interface.Array arr cs e, GHC.Classes.Eq (Graphics.Image.Interface.Pixel cs e)) => GHC.Classes.Eq (Graphics.Image.Interface.Image arr cs e) instance Graphics.Image.Interface.Array arr cs e => GHC.Num.Num (Graphics.Image.Interface.Image arr cs e) instance (GHC.Real.Fractional (Graphics.Image.Interface.Pixel cs e), Graphics.Image.Interface.Array arr cs e) => GHC.Real.Fractional (Graphics.Image.Interface.Image arr cs e) instance (GHC.Float.Floating (Graphics.Image.Interface.Pixel cs e), Graphics.Image.Interface.Array arr cs e) => GHC.Float.Floating (Graphics.Image.Interface.Image arr cs e) instance Graphics.Image.Interface.MArray arr cs e => Control.DeepSeq.NFData (Graphics.Image.Interface.Image arr cs e) instance Graphics.Image.Interface.BaseArray arr cs e => GHC.Show.Show (Graphics.Image.Interface.Image arr cs e) instance Graphics.Image.Interface.MArray arr cs e => GHC.Show.Show (Graphics.Image.Interface.MImage st arr cs e) module Graphics.Image.Interface.Vector -- | Unboxed Vector representation. data VU VU :: VU -- | Storable Vector representation. data VS VS :: VS -- | Filter out Pixels from an image that do not satisfy the predicate and -- convert a result into a flat unboxed vector with indexed Pixels. filter :: Array arr cs e => (Pixel cs e -> Bool) -> Image arr cs e -> Vector ((Int, Int), Pixel cs e) -- | Filter out Pixels from an image that do not satisfy the index aware -- predicate and convert a result into a flat unboxed vector with indexed -- Pixels. ifilter :: Array arr cs e => ((Int, Int) -> Pixel cs e -> Bool) -> Image arr cs e -> Vector ((Int, Int), Pixel cs e) -- | Flat vector to 2D index conversion. toIx :: Int -> Int -> (Int, Int) -- | 2D to a flat vector index conversion. -- -- Note: There is an implicit assumption that j < n fromIx :: Int -> (Int, Int) -> Int module Graphics.Image.Processing.Complex -- | Construct a complex image from two images representing real and -- imaginary parts. -- --
--   >>> frog <- readImageRGB VU "images/frog.jpg"
--   
--   >>> frog !+! 0
--   <Image VectorUnboxed RGB (Complex Double): 200x320>
--   
--   >>> frog !+! frog
--   <Image VectorUnboxed RGB (Complex Double): 200x320>
--   
(!+!) :: (Applicative (Pixel cs), Array arr cs e, Array arr cs (Complex e)) => Image arr cs e -> Image arr cs e -> Image arr cs (Complex e) infix 6 !+! -- | Extracts the real part of a complex image. realPartI :: (Applicative (Pixel cs), Array arr cs e, Array arr cs (Complex e), RealFloat e) => Image arr cs (Complex e) -> Image arr cs e -- | Extracts the imaginary part of a complex image. imagPartI :: (Applicative (Pixel cs), Array arr cs e, Array arr cs (Complex e), RealFloat e) => Image arr cs (Complex e) -> Image arr cs e -- | Form a complex image from polar components of magnitude and phase. mkPolarI :: (Applicative (Pixel cs), Array arr cs e, Array arr cs (Complex e), RealFloat e) => Image arr cs e -> Image arr cs e -> Image arr cs (Complex e) -- | cisI t is a complex image with magnitude 1 and phase t -- (modulo 2*pi). cisI :: (Applicative (Pixel cs), Array arr cs e, Array arr cs (Complex e), RealFloat e) => Image arr cs e -> Image arr cs (Complex e) -- | The function polar' takes a complex image and -- returns a (magnitude, phase) pair of images in canonical form: the -- magnitude is nonnegative, and the phase in the range (-pi, -- pi]; if the magnitude is zero, then so is the phase. polarI :: (Applicative (Pixel cs), Array arr cs e, Array arr cs (Complex e), RealFloat e) => Image arr cs (Complex e) -> (Image arr cs e, Image arr cs e) -- | The nonnegative magnitude of a complex image. magnitudeI :: (Applicative (Pixel cs), Array arr cs e, Array arr cs (Complex e), RealFloat e) => Image arr cs (Complex e) -> Image arr cs e -- | The phase of a complex image, in the range (-pi, -- pi]. If the magnitude is zero, then so is the phase. phaseI :: (Applicative (Pixel cs), Array arr cs e, Array arr cs (Complex e), RealFloat e) => Image arr cs (Complex e) -> Image arr cs e -- | The conjugate of a complex image. conjugateI :: (Applicative (Pixel cs), Array arr cs (Complex e), RealFloat e) => Image arr cs (Complex e) -> Image arr cs (Complex e) -- | Make a filter by using a function that works around a regular (x, -- y) coordinate system. makeFilter :: (Array arr cs e, RealFloat e) => (Int, Int) -> ((Int, Int) -> Pixel cs e) -> Image arr cs e -- | Apply a filter to an image created by makeFilter. applyFilter :: (Applicative (Pixel cs), Array arr cs e, Array arr cs (Complex e), Fractional (Pixel cs (Complex e)), Floating (Pixel cs e), RealFloat e) => Image arr cs e -> Image arr cs e -> Image arr cs e -- | Fast Fourier Transform fft :: (Applicative (Pixel cs), Array arr cs (Complex e), ColorSpace cs e, Fractional (Pixel cs (Complex e)), Floating (Pixel cs e), RealFloat e) => Image arr cs (Complex e) -> Image arr cs (Complex e) -- | Inverse Fast Fourier Transform ifft :: (Applicative (Pixel cs), Array arr cs (Complex e), ColorSpace cs e, Fractional (Pixel cs (Complex e)), Floating (Pixel cs e), RealFloat e) => Image arr cs (Complex e) -> Image arr cs (Complex e) module Graphics.Image.Interface.Repa -- | Create a sequential unboxed image from a 2D Repa delayed array. fromRepaArrayS :: Source r (Pixel cs e) => Array r DIM2 (Pixel cs e) -> Image RSU cs e -- | Create a parallel unboxed image from a 2D Repa delayed array. fromRepaArrayP :: Source r (Pixel cs e) => Array r DIM2 (Pixel cs e) -> Image RPU cs e -- | Convert into Repa Unboxed array from an image. toRepaArray :: Array arr cs e => Image arr cs e -> Array U DIM2 (Pixel cs e) -- | Repa Array representation backed by Unboxed Vector, which is computed -- sequentially. data RSU RSU :: RSU -- | Repa Array representation backed by Unboxed Vector, which is computed -- in parallel. data RPU RPU :: RPU -- | Repa Array representation backed by Storable Vector, which is computed -- sequentially. data RSS RSS :: RSS -- | Repa Array representation backed by Storable Vector, which is computed -- in parallel. data RPS RPS :: RPS module Graphics.Image.ColorSpace -- | A Pixel family with a color space and a precision of elements. -- | Convert a pixel to Luma pixel. toPixelY :: ToY cs e => Pixel cs e -> Pixel Y Double -- | Convert an image to Luma image. toImageY :: (ToY cs e, Array arr cs e, Array arr Y Double) => Image arr cs e -> Image arr Y Double -- | Convert a pixel to Luma pixel with Alpha. toPixelYA :: ToYA cs e => Pixel cs e -> Pixel YA Double -- | Convert an image to Luma image with Alpha. toImageYA :: (ToYA cs e, Array arr cs e, Array arr YA Double) => Image arr cs e -> Image arr YA Double -- | Convert to an RGB pixel. toPixelRGB :: ToRGB cs e => Pixel cs e -> Pixel RGB Double -- | Convert to an RGB image. toImageRGB :: (ToRGB cs e, Array arr cs e, Array arr RGB Double) => Image arr cs e -> Image arr RGB Double -- | Convert to an RGBA pixel. toPixelRGBA :: ToRGBA cs e => Pixel cs e -> Pixel RGBA Double -- | Convert to an RGBA image. toImageRGBA :: (ToRGBA cs e, Array arr cs e, Array arr RGBA Double) => Image arr cs e -> Image arr RGBA Double -- | Convert to an HSI pixel. toPixelHSI :: ToHSI cs e => Pixel cs e -> Pixel HSI Double -- | Convert to an HSI image. toImageHSI :: (ToHSI cs e, Array arr cs e, Array arr HSI Double) => Image arr cs e -> Image arr HSI Double -- | Convert to an HSIA pixel. toPixelHSIA :: ToHSIA cs e => Pixel cs e -> Pixel HSIA Double -- | Convert to an HSIA image. toImageHSIA :: (ToHSIA cs e, Array arr cs e, Array arr HSIA Double) => Image arr cs e -> Image arr HSIA Double -- | Convert to a CMYK pixel. toPixelCMYK :: ToCMYK cs e => Pixel cs e -> Pixel CMYK Double -- | Convert to a CMYK image. toImageCMYK :: (ToCMYK cs e, Array arr cs e, Array arr CMYK Double) => Image arr cs e -> Image arr CMYK Double -- | Convert to a CMYKA pixel. toPixelCMYKA :: ToCMYKA cs e => Pixel cs e -> Pixel CMYKA Double -- | Convert to a CMYKA image. toImageCMYKA :: (ToCMYKA cs e, Array arr cs e, Array arr CMYKA Double) => Image arr cs e -> Image arr CMYKA Double -- | Convert to an YCbCr pixel. toPixelYCbCr :: ToYCbCr cs e => Pixel cs e -> Pixel YCbCr Double -- | Convert to an YCbCr image. toImageYCbCr :: (ToYCbCr cs e, Array arr cs e, Array arr YCbCr Double) => Image arr cs e -> Image arr YCbCr Double -- | Convert to an YCbCrA pixel. toPixelYCbCrA :: ToYCbCrA cs e => Pixel cs e -> Pixel YCbCrA Double -- | Convert to an YCbCrA image. toImageYCbCrA :: (ToYCbCrA cs e, Array arr cs e, Array arr YCbCrA Double) => Image arr cs e -> Image arr YCbCrA Double -- | Represents value True or 1 in binary. Often also -- called a foreground pixel of an object. on :: Pixel Binary Bit -- | Represents value False or 0 in binary. Often also -- called a background pixel. off :: Pixel Binary Bit -- | Test if Pixel's value is on. isOn :: Pixel Binary Bit -> Bool -- | Test if Pixel's value is off. isOff :: Pixel Binary Bit -> Bool one :: Bit zero :: Bit -- | Convert a Bool to a PixelBin pixel. -- --
--   >>> isOn (fromBool True)
--   True
--   
fromBool :: Bool -> Pixel Binary Bit -- | Reverse all the bits in the argument complement :: Bits a => a -> a -- | Convert to a Binary pixel. toPixelBinary :: ColorSpace cs e => Pixel cs e -> Pixel Binary Bit -- | Convert a Binary pixel to Luma pixel fromPixelBinary :: Pixel Binary Bit -> Pixel Y Word8 -- | Convert to a Binary image. toImageBinary :: (Array arr cs e, Array arr Binary Bit) => Image arr cs e -> Image arr Binary Bit -- | Convert a Binary image to Luma image fromImageBinary :: (Array arr Binary Bit, Array arr Y Word8) => Image arr Binary Bit -> Image arr Y Word8 -- | Complex numbers are an algebraic type. -- -- For a complex number z, abs z is a number -- with the magnitude of z, but oriented in the positive real -- direction, whereas signum z has the phase of -- z, but unit magnitude. -- -- The Foldable and Traversable instances traverse the real -- part first. data Complex a :: * -> * -- | forms a complex number from its real and imaginary rectangular -- components. (:+) :: ~a -> ~a -> Complex a -- | Constrcut a complex pixel from two pixels representing real and -- imaginary parts. -- --
--   PixelRGB 4 8 6 +: PixelRGB 7 1 1 == PixelRGB (4 :+ 7) (8 :+ 1) (6 :+ 1)
--   
(+:) :: Applicative (Pixel cs) => Pixel cs e -> Pixel cs e -> Pixel cs (Complex e) infix 6 +: -- | Extracts the real part of a complex pixel. realPart :: (Applicative (Pixel cs), RealFloat e) => Pixel cs (Complex e) -> Pixel cs e -- | Extracts the imaginary part of a complex pixel. imagPart :: (Applicative (Pixel cs), RealFloat e) => Pixel cs (Complex e) -> Pixel cs e -- | Form a complex pixel from polar components of magnitude and phase. mkPolar :: (Applicative (Pixel cs), RealFloat e) => Pixel cs e -> Pixel cs e -> Pixel cs (Complex e) -- | cis t is a complex pixel with magnitude 1 and phase t -- (modulo 2*pi). cis :: (Applicative (Pixel cs), RealFloat e) => Pixel cs e -> Pixel cs (Complex e) -- | The function polar takes a complex pixel and returns a -- (magnitude, phase) pair of pixels in canonical form: the magnitude is -- nonnegative, and the phase in the range (-pi, -- pi]; if the magnitude is zero, then so is the phase. polar :: (Applicative (Pixel cs), RealFloat e) => Pixel cs (Complex e) -> (Pixel cs e, Pixel cs e) -- | The nonnegative magnitude of a complex pixel. magnitude :: (Applicative (Pixel cs), RealFloat e) => Pixel cs (Complex e) -> Pixel cs e -- | The phase of a complex pixel, in the range (-pi, -- pi]. If the magnitude is zero, then so is the phase. phase :: (Applicative (Pixel cs), RealFloat e) => Pixel cs (Complex e) -> Pixel cs e -- | The conjugate of a complex pixel. conjugate :: (Applicative (Pixel cs), RealFloat e) => Pixel cs (Complex e) -> Pixel cs (Complex e) -- | Separate a Pixel into a list of components with X pixels -- containing every component from the pixel. -- --
--   >>> toPixelsX (PixelRGB 4 5 6)
--   [<X:(4)>,<X:(5)>,<X:(6)>]
--   
toPixelsX :: ColorSpace cs e => Pixel cs e -> [Pixel X e] -- | Combine a list of X pixels into a Pixel with a specified -- channel order. Not the most efficient way to construct a pixel, but -- might prove useful to someone. -- --
--   >>> fromPixelsX [(RedRGB, 3), (BlueRGB, 5), (GreenRGB, 4)]
--   <RGB:(3.0|4.0|5.0)>
--   
--   >>> fromPixelsX $ zip (enumFrom RedRGB) (toPixelsX $ PixelRGB 4 5 6)
--   <RGB:(4.0|5.0|6.0)>
--   
fromPixelsX :: ColorSpace cs e => [(cs, Pixel X e)] -> Pixel cs e -- | Separate an image into a list of images with X pixels -- containing every channel from the source image. -- --
--   >>> frog <- readImageRGB "images/frog.jpg"
--   
--   >>> let [frog_red, frog_green, frog_blue] = toImagesX frog
--   
--   >>> writeImage "images/frog_red.png" $ toImageY frog_red
--   
--   >>> writeImage "images/frog_green.jpg" $ toImageY frog_green
--   
--   >>> writeImage "images/frog_blue.jpg" $ toImageY frog_blue
--   
-- toImagesX :: (Array arr cs e, Array arr X e) => Image arr cs e -> [Image arr X e] -- | Combine a list of images with X pixels into an image of any -- color space, by supplying an order of color space channels. -- -- For example here is a frog with swapped BlueRGB and -- GreenRGB channels. -- --
--   >>> writeImage "images/frog_rbg.jpg" $ fromImagesX [(RedRGB, frog_red), (BlueRGB, frog_green), (GreenRGB, frog_blue)]
--   
-- -- -- It is worth noting though, despite that separating image channels can -- be sometimes pretty useful, exactly the same effect as in example -- above can be achieved in a much simpler and a more efficient way: -- --
--   map (\(PixelRGB r g b) -> PixelRGB r b g) frog
--   
fromImagesX :: (Array arr X e, Array arr cs e) => [(cs, Image arr X e)] -> Image arr cs e -- | Check weather two Pixels are equal within a tolerance. Useful for -- comparing pixels with Float or Double precision. eqTolPx :: (ColorSpace cs e, Ord e) => e -> Pixel cs e -> Pixel cs e -> Bool -- | Luma or brightness, which is usually denoted as Y'. data Y LumaY :: Y -- | Luma with Alpha channel. data YA -- | Luma LumaYA :: YA -- | Alpha channel AlphaYA :: YA -- | Conversion to Luma color space. class ColorSpace cs e => ToY cs e -- | Convert a pixel to Luma pixel. toPixelY :: ToY cs e => Pixel cs e -> Pixel Y Double -- | Conversion to Luma from another color space. class ToY cs e => ToYA cs e where toPixelYA = addAlpha 1 . toPixelY -- | Convert a pixel to Luma pixel with Alpha. toPixelYA :: ToYA cs e => Pixel cs e -> Pixel YA Double -- | Red, Green and Blue color space. data RGB RedRGB :: RGB GreenRGB :: RGB BlueRGB :: RGB -- | Red, Green and Blue color space with Alpha channel. data RGBA RedRGBA :: RGBA GreenRGBA :: RGBA BlueRGBA :: RGBA AlphaRGBA :: RGBA -- | Conversion to RGB color space. class ColorSpace cs e => ToRGB cs e -- | Convert to an RGB pixel. toPixelRGB :: ToRGB cs e => Pixel cs e -> Pixel RGB Double -- | Conversion to RGBA from another color space with Alpha channel. class ToRGB cs e => ToRGBA cs e where toPixelRGBA = addAlpha 1 . toPixelRGB -- | Convert to an RGBA pixel. toPixelRGBA :: ToRGBA cs e => Pixel cs e -> Pixel RGBA Double -- | Hue, Saturation and Intensity color space. data HSI -- | Hue HueHSI :: HSI -- | Saturation SatHSI :: HSI -- | Intensity IntHSI :: HSI -- | Hue, Saturation and Intensity color space with Alpha channel. data HSIA -- | Hue HueHSIA :: HSIA -- | Saturation SatHSIA :: HSIA -- | Intensity IntHSIA :: HSIA -- | Alpha AlphaHSIA :: HSIA -- | Conversion to HSI color space. class ColorSpace cs e => ToHSI cs e -- | Convert to an HSI pixel. toPixelHSI :: ToHSI cs e => Pixel cs e -> Pixel HSI Double -- | Conversion to HSIA from another color space with Alpha channel. class ToHSI cs e => ToHSIA cs e where toPixelHSIA = addAlpha 1 . toPixelHSI -- | Convert to an HSIA pixel. toPixelHSIA :: ToHSIA cs e => Pixel cs e -> Pixel HSIA Double -- | Cyan, Magenta, Yellow and Black color space. data CMYK -- | Cyan CyanCMYK :: CMYK -- | Magenta MagCMYK :: CMYK -- | Yellow YelCMYK :: CMYK -- | Key (Black) KeyCMYK :: CMYK -- | Cyan, Magenta, Yellow and Black color space with Alpha channel. data CMYKA -- | Cyan CyanCMYKA :: CMYKA -- | Magenta MagCMYKA :: CMYKA -- | Yellow YelCMYKA :: CMYKA -- | Key (Black) KeyCMYKA :: CMYKA -- | Alpha AlphaCMYKA :: CMYKA -- | Conversion to CMYK color space. class ColorSpace cs e => ToCMYK cs e -- | Convert to a CMYK pixel. toPixelCMYK :: ToCMYK cs e => Pixel cs e -> Pixel CMYK Double -- | Conversion to CMYKA. class ToCMYK cs e => ToCMYKA cs e where toPixelCMYKA = addAlpha 1 . toPixelCMYK -- | Convert to a CMYKA pixel. toPixelCMYKA :: ToCMYKA cs e => Pixel cs e -> Pixel CMYKA Double -- | Color space is used to encode RGB information and is used in JPEG -- compression. data YCbCr -- | Luma component (commonly denoted as Y') LumaYCbCr :: YCbCr -- | Blue difference chroma component CBlueYCbCr :: YCbCr -- | Red difference chroma component CRedYCbCr :: YCbCr -- | YCbCr color space with Alpha channel. data YCbCrA -- | Luma component (commonly denoted as Y') LumaYCbCrA :: YCbCrA -- | Blue difference chroma component CBlueYCbCrA :: YCbCrA -- | Red difference chroma component CRedYCbCrA :: YCbCrA -- | Alpha component. AlphaYCbCrA :: YCbCrA -- | Conversion to YCbCr color space. class ColorSpace cs e => ToYCbCr cs e -- | Convert to an YCbCr pixel. toPixelYCbCr :: ToYCbCr cs e => Pixel cs e -> Pixel YCbCr Double -- | Conversion to YCbCrA from another color space with Alpha -- channel. class ToYCbCr cs e => ToYCbCrA cs e where toPixelYCbCrA = addAlpha 1 . toPixelYCbCr -- | Convert to an YCbCrA pixel. toPixelYCbCrA :: ToYCbCrA cs e => Pixel cs e -> Pixel YCbCrA Double -- | Binary Color Space, also known as bi-tonal. data Binary Binary :: Binary -- | Under the hood, Binary pixels are represented as Word8, but can -- only take values of 0 or 1. data Bit -- | This is a single channel colorspace, that is designed to separate Gray -- level values from other types of colorspace, hence it is not -- convertible to or from, but rather is here to allow operation on -- arbirtary single channel images. If you are looking for a true -- grayscale colorspace Y should be used instead. data X X :: X -- | 8-bit unsigned integer type data Word8 :: * -- | 16-bit unsigned integer type data Word16 :: * -- | 32-bit unsigned integer type data Word32 :: * -- | 64-bit unsigned integer type data Word64 :: * instance Graphics.Image.Interface.Elevator.Elevator e => Graphics.Image.ColorSpace.ToY Graphics.Image.ColorSpace.X.X e instance Graphics.Image.ColorSpace.ToY Graphics.Image.ColorSpace.Binary.Binary Graphics.Image.ColorSpace.Binary.Bit instance Graphics.Image.Interface.Elevator.Elevator e => Graphics.Image.ColorSpace.ToY Graphics.Image.ColorSpace.Y.Y e instance Graphics.Image.Interface.Elevator.Elevator e => Graphics.Image.ColorSpace.ToY Graphics.Image.ColorSpace.Y.YA e instance Graphics.Image.Interface.Elevator.Elevator e => Graphics.Image.ColorSpace.ToY Graphics.Image.ColorSpace.RGB.RGB e instance Graphics.Image.Interface.Elevator.Elevator e => Graphics.Image.ColorSpace.ToY Graphics.Image.ColorSpace.RGB.RGBA e instance Graphics.Image.Interface.Elevator.Elevator e => Graphics.Image.ColorSpace.ToY Graphics.Image.ColorSpace.HSI.HSI e instance Graphics.Image.Interface.Elevator.Elevator e => Graphics.Image.ColorSpace.ToY Graphics.Image.ColorSpace.HSI.HSIA e instance Graphics.Image.Interface.Elevator.Elevator e => Graphics.Image.ColorSpace.ToY Graphics.Image.ColorSpace.CMYK.CMYK e instance Graphics.Image.Interface.Elevator.Elevator e => Graphics.Image.ColorSpace.ToY Graphics.Image.ColorSpace.CMYK.CMYKA e instance Graphics.Image.Interface.Elevator.Elevator e => Graphics.Image.ColorSpace.ToY Graphics.Image.ColorSpace.YCbCr.YCbCr e instance Graphics.Image.Interface.Elevator.Elevator e => Graphics.Image.ColorSpace.ToY Graphics.Image.ColorSpace.YCbCr.YCbCrA e instance Graphics.Image.ColorSpace.ToY Graphics.Image.ColorSpace.Y.Y e => Graphics.Image.ColorSpace.ToYA Graphics.Image.ColorSpace.Y.Y e instance Graphics.Image.ColorSpace.ToYA Graphics.Image.ColorSpace.Binary.Binary Graphics.Image.ColorSpace.Binary.Bit instance Graphics.Image.Interface.Elevator.Elevator e => Graphics.Image.ColorSpace.ToYA Graphics.Image.ColorSpace.Y.YA e instance Graphics.Image.ColorSpace.ToY Graphics.Image.ColorSpace.RGB.RGB e => Graphics.Image.ColorSpace.ToYA Graphics.Image.ColorSpace.RGB.RGB e instance Graphics.Image.Interface.Elevator.Elevator e => Graphics.Image.ColorSpace.ToYA Graphics.Image.ColorSpace.RGB.RGBA e instance Graphics.Image.ColorSpace.ToY Graphics.Image.ColorSpace.HSI.HSI e => Graphics.Image.ColorSpace.ToYA Graphics.Image.ColorSpace.HSI.HSI e instance Graphics.Image.Interface.Elevator.Elevator e => Graphics.Image.ColorSpace.ToYA Graphics.Image.ColorSpace.HSI.HSIA e instance Graphics.Image.ColorSpace.ToY Graphics.Image.ColorSpace.CMYK.CMYK e => Graphics.Image.ColorSpace.ToYA Graphics.Image.ColorSpace.CMYK.CMYK e instance Graphics.Image.Interface.Elevator.Elevator e => Graphics.Image.ColorSpace.ToYA Graphics.Image.ColorSpace.CMYK.CMYKA e instance Graphics.Image.ColorSpace.ToY Graphics.Image.ColorSpace.YCbCr.YCbCr e => Graphics.Image.ColorSpace.ToYA Graphics.Image.ColorSpace.YCbCr.YCbCr e instance Graphics.Image.Interface.Elevator.Elevator e => Graphics.Image.ColorSpace.ToYA Graphics.Image.ColorSpace.YCbCr.YCbCrA e instance Graphics.Image.ColorSpace.ToRGB Graphics.Image.ColorSpace.Binary.Binary Graphics.Image.ColorSpace.Binary.Bit instance Graphics.Image.Interface.Elevator.Elevator e => Graphics.Image.ColorSpace.ToRGB Graphics.Image.ColorSpace.Y.Y e instance Graphics.Image.Interface.Elevator.Elevator e => Graphics.Image.ColorSpace.ToRGB Graphics.Image.ColorSpace.Y.YA e instance Graphics.Image.Interface.Elevator.Elevator e => Graphics.Image.ColorSpace.ToRGB Graphics.Image.ColorSpace.RGB.RGB e instance Graphics.Image.Interface.Elevator.Elevator e => Graphics.Image.ColorSpace.ToRGB Graphics.Image.ColorSpace.RGB.RGBA e instance Graphics.Image.Interface.Elevator.Elevator e => Graphics.Image.ColorSpace.ToRGB Graphics.Image.ColorSpace.HSI.HSI e instance Graphics.Image.Interface.Elevator.Elevator e => Graphics.Image.ColorSpace.ToRGB Graphics.Image.ColorSpace.HSI.HSIA e instance Graphics.Image.Interface.Elevator.Elevator e => Graphics.Image.ColorSpace.ToRGB Graphics.Image.ColorSpace.YCbCr.YCbCr e instance Graphics.Image.Interface.Elevator.Elevator e => Graphics.Image.ColorSpace.ToRGB Graphics.Image.ColorSpace.YCbCr.YCbCrA e instance Graphics.Image.Interface.Elevator.Elevator e => Graphics.Image.ColorSpace.ToRGB Graphics.Image.ColorSpace.CMYK.CMYK e instance Graphics.Image.Interface.Elevator.Elevator e => Graphics.Image.ColorSpace.ToRGB Graphics.Image.ColorSpace.CMYK.CMYKA e instance Graphics.Image.ColorSpace.ToRGBA Graphics.Image.ColorSpace.Binary.Binary Graphics.Image.ColorSpace.Binary.Bit instance Graphics.Image.ColorSpace.ToRGB Graphics.Image.ColorSpace.Y.Y e => Graphics.Image.ColorSpace.ToRGBA Graphics.Image.ColorSpace.Y.Y e instance Graphics.Image.Interface.Elevator.Elevator e => Graphics.Image.ColorSpace.ToRGBA Graphics.Image.ColorSpace.Y.YA e instance Graphics.Image.ColorSpace.ToRGB Graphics.Image.ColorSpace.RGB.RGB e => Graphics.Image.ColorSpace.ToRGBA Graphics.Image.ColorSpace.RGB.RGB e instance Graphics.Image.Interface.Elevator.Elevator e => Graphics.Image.ColorSpace.ToRGBA Graphics.Image.ColorSpace.RGB.RGBA e instance Graphics.Image.ColorSpace.ToRGB Graphics.Image.ColorSpace.HSI.HSI e => Graphics.Image.ColorSpace.ToRGBA Graphics.Image.ColorSpace.HSI.HSI e instance Graphics.Image.Interface.Elevator.Elevator e => Graphics.Image.ColorSpace.ToRGBA Graphics.Image.ColorSpace.HSI.HSIA e instance Graphics.Image.ColorSpace.ToRGB Graphics.Image.ColorSpace.CMYK.CMYK e => Graphics.Image.ColorSpace.ToRGBA Graphics.Image.ColorSpace.CMYK.CMYK e instance Graphics.Image.Interface.Elevator.Elevator e => Graphics.Image.ColorSpace.ToRGBA Graphics.Image.ColorSpace.CMYK.CMYKA e instance Graphics.Image.ColorSpace.ToRGB Graphics.Image.ColorSpace.YCbCr.YCbCr e => Graphics.Image.ColorSpace.ToRGBA Graphics.Image.ColorSpace.YCbCr.YCbCr e instance Graphics.Image.Interface.Elevator.Elevator e => Graphics.Image.ColorSpace.ToRGBA Graphics.Image.ColorSpace.YCbCr.YCbCrA e instance Graphics.Image.Interface.Elevator.Elevator e => Graphics.Image.ColorSpace.ToHSI Graphics.Image.ColorSpace.Y.Y e instance Graphics.Image.Interface.Elevator.Elevator e => Graphics.Image.ColorSpace.ToHSI Graphics.Image.ColorSpace.Y.YA e instance Graphics.Image.Interface.Elevator.Elevator e => Graphics.Image.ColorSpace.ToHSI Graphics.Image.ColorSpace.RGB.RGB e instance Graphics.Image.Interface.Elevator.Elevator e => Graphics.Image.ColorSpace.ToHSI Graphics.Image.ColorSpace.RGB.RGBA e instance Graphics.Image.Interface.Elevator.Elevator e => Graphics.Image.ColorSpace.ToHSI Graphics.Image.ColorSpace.HSI.HSI e instance Graphics.Image.Interface.Elevator.Elevator e => Graphics.Image.ColorSpace.ToHSI Graphics.Image.ColorSpace.HSI.HSIA e instance Graphics.Image.Interface.Elevator.Elevator e => Graphics.Image.ColorSpace.ToHSI Graphics.Image.ColorSpace.YCbCr.YCbCr e instance Graphics.Image.Interface.Elevator.Elevator e => Graphics.Image.ColorSpace.ToHSI Graphics.Image.ColorSpace.YCbCr.YCbCrA e instance Graphics.Image.Interface.Elevator.Elevator e => Graphics.Image.ColorSpace.ToHSI Graphics.Image.ColorSpace.CMYK.CMYK e instance Graphics.Image.Interface.Elevator.Elevator e => Graphics.Image.ColorSpace.ToHSI Graphics.Image.ColorSpace.CMYK.CMYKA e instance Graphics.Image.ColorSpace.ToHSI Graphics.Image.ColorSpace.Y.Y e => Graphics.Image.ColorSpace.ToHSIA Graphics.Image.ColorSpace.Y.Y e instance Graphics.Image.Interface.Elevator.Elevator e => Graphics.Image.ColorSpace.ToHSIA Graphics.Image.ColorSpace.Y.YA e instance Graphics.Image.ColorSpace.ToHSI Graphics.Image.ColorSpace.RGB.RGB e => Graphics.Image.ColorSpace.ToHSIA Graphics.Image.ColorSpace.RGB.RGB e instance Graphics.Image.Interface.Elevator.Elevator e => Graphics.Image.ColorSpace.ToHSIA Graphics.Image.ColorSpace.RGB.RGBA e instance Graphics.Image.ColorSpace.ToHSI Graphics.Image.ColorSpace.HSI.HSI e => Graphics.Image.ColorSpace.ToHSIA Graphics.Image.ColorSpace.HSI.HSI e instance Graphics.Image.Interface.Elevator.Elevator e => Graphics.Image.ColorSpace.ToHSIA Graphics.Image.ColorSpace.HSI.HSIA e instance Graphics.Image.ColorSpace.ToHSI Graphics.Image.ColorSpace.CMYK.CMYK e => Graphics.Image.ColorSpace.ToHSIA Graphics.Image.ColorSpace.CMYK.CMYK e instance Graphics.Image.Interface.Elevator.Elevator e => Graphics.Image.ColorSpace.ToHSIA Graphics.Image.ColorSpace.CMYK.CMYKA e instance Graphics.Image.ColorSpace.ToHSI Graphics.Image.ColorSpace.YCbCr.YCbCr e => Graphics.Image.ColorSpace.ToHSIA Graphics.Image.ColorSpace.YCbCr.YCbCr e instance Graphics.Image.Interface.Elevator.Elevator e => Graphics.Image.ColorSpace.ToHSIA Graphics.Image.ColorSpace.YCbCr.YCbCrA e instance Graphics.Image.Interface.Elevator.Elevator e => Graphics.Image.ColorSpace.ToCMYK Graphics.Image.ColorSpace.Y.Y e instance Graphics.Image.Interface.Elevator.Elevator e => Graphics.Image.ColorSpace.ToCMYK Graphics.Image.ColorSpace.Y.YA e instance Graphics.Image.Interface.Elevator.Elevator e => Graphics.Image.ColorSpace.ToCMYK Graphics.Image.ColorSpace.RGB.RGB e instance Graphics.Image.Interface.Elevator.Elevator e => Graphics.Image.ColorSpace.ToCMYK Graphics.Image.ColorSpace.RGB.RGBA e instance Graphics.Image.Interface.Elevator.Elevator e => Graphics.Image.ColorSpace.ToCMYK Graphics.Image.ColorSpace.HSI.HSI e instance Graphics.Image.Interface.Elevator.Elevator e => Graphics.Image.ColorSpace.ToCMYK Graphics.Image.ColorSpace.HSI.HSIA e instance Graphics.Image.Interface.Elevator.Elevator e => Graphics.Image.ColorSpace.ToCMYK Graphics.Image.ColorSpace.CMYK.CMYK e instance Graphics.Image.Interface.Elevator.Elevator e => Graphics.Image.ColorSpace.ToCMYK Graphics.Image.ColorSpace.CMYK.CMYKA e instance Graphics.Image.Interface.Elevator.Elevator e => Graphics.Image.ColorSpace.ToCMYK Graphics.Image.ColorSpace.YCbCr.YCbCr e instance Graphics.Image.Interface.Elevator.Elevator e => Graphics.Image.ColorSpace.ToCMYK Graphics.Image.ColorSpace.YCbCr.YCbCrA e instance Graphics.Image.ColorSpace.ToCMYK Graphics.Image.ColorSpace.Y.Y e => Graphics.Image.ColorSpace.ToCMYKA Graphics.Image.ColorSpace.Y.Y e instance Graphics.Image.Interface.Elevator.Elevator e => Graphics.Image.ColorSpace.ToCMYKA Graphics.Image.ColorSpace.Y.YA e instance Graphics.Image.ColorSpace.ToCMYK Graphics.Image.ColorSpace.RGB.RGB e => Graphics.Image.ColorSpace.ToCMYKA Graphics.Image.ColorSpace.RGB.RGB e instance Graphics.Image.Interface.Elevator.Elevator e => Graphics.Image.ColorSpace.ToCMYKA Graphics.Image.ColorSpace.RGB.RGBA e instance Graphics.Image.ColorSpace.ToCMYK Graphics.Image.ColorSpace.HSI.HSI e => Graphics.Image.ColorSpace.ToCMYKA Graphics.Image.ColorSpace.HSI.HSI e instance Graphics.Image.Interface.Elevator.Elevator e => Graphics.Image.ColorSpace.ToCMYKA Graphics.Image.ColorSpace.HSI.HSIA e instance Graphics.Image.ColorSpace.ToCMYK Graphics.Image.ColorSpace.CMYK.CMYK e => Graphics.Image.ColorSpace.ToCMYKA Graphics.Image.ColorSpace.CMYK.CMYK e instance Graphics.Image.Interface.Elevator.Elevator e => Graphics.Image.ColorSpace.ToCMYKA Graphics.Image.ColorSpace.CMYK.CMYKA e instance Graphics.Image.ColorSpace.ToCMYK Graphics.Image.ColorSpace.YCbCr.YCbCr e => Graphics.Image.ColorSpace.ToCMYKA Graphics.Image.ColorSpace.YCbCr.YCbCr e instance Graphics.Image.Interface.Elevator.Elevator e => Graphics.Image.ColorSpace.ToCMYKA Graphics.Image.ColorSpace.YCbCr.YCbCrA e instance Graphics.Image.Interface.Elevator.Elevator e => Graphics.Image.ColorSpace.ToYCbCr Graphics.Image.ColorSpace.Y.Y e instance Graphics.Image.Interface.Elevator.Elevator e => Graphics.Image.ColorSpace.ToYCbCr Graphics.Image.ColorSpace.Y.YA e instance Graphics.Image.Interface.Elevator.Elevator e => Graphics.Image.ColorSpace.ToYCbCr Graphics.Image.ColorSpace.RGB.RGB e instance Graphics.Image.Interface.Elevator.Elevator e => Graphics.Image.ColorSpace.ToYCbCr Graphics.Image.ColorSpace.RGB.RGBA e instance Graphics.Image.Interface.Elevator.Elevator e => Graphics.Image.ColorSpace.ToYCbCr Graphics.Image.ColorSpace.HSI.HSI e instance Graphics.Image.Interface.Elevator.Elevator e => Graphics.Image.ColorSpace.ToYCbCr Graphics.Image.ColorSpace.HSI.HSIA e instance Graphics.Image.Interface.Elevator.Elevator e => Graphics.Image.ColorSpace.ToYCbCr Graphics.Image.ColorSpace.YCbCr.YCbCr e instance Graphics.Image.Interface.Elevator.Elevator e => Graphics.Image.ColorSpace.ToYCbCr Graphics.Image.ColorSpace.YCbCr.YCbCrA e instance Graphics.Image.Interface.Elevator.Elevator e => Graphics.Image.ColorSpace.ToYCbCr Graphics.Image.ColorSpace.CMYK.CMYK e instance Graphics.Image.Interface.Elevator.Elevator e => Graphics.Image.ColorSpace.ToYCbCr Graphics.Image.ColorSpace.CMYK.CMYKA e instance Graphics.Image.ColorSpace.ToYCbCr Graphics.Image.ColorSpace.Y.Y e => Graphics.Image.ColorSpace.ToYCbCrA Graphics.Image.ColorSpace.Y.Y e instance Graphics.Image.Interface.Elevator.Elevator e => Graphics.Image.ColorSpace.ToYCbCrA Graphics.Image.ColorSpace.Y.YA e instance Graphics.Image.ColorSpace.ToYCbCr Graphics.Image.ColorSpace.RGB.RGB e => Graphics.Image.ColorSpace.ToYCbCrA Graphics.Image.ColorSpace.RGB.RGB e instance Graphics.Image.ColorSpace.ToYCbCr Graphics.Image.ColorSpace.HSI.HSI e => Graphics.Image.ColorSpace.ToYCbCrA Graphics.Image.ColorSpace.HSI.HSI e instance Graphics.Image.Interface.Elevator.Elevator e => Graphics.Image.ColorSpace.ToYCbCrA Graphics.Image.ColorSpace.HSI.HSIA e instance Graphics.Image.Interface.Elevator.Elevator e => Graphics.Image.ColorSpace.ToYCbCrA Graphics.Image.ColorSpace.RGB.RGBA e instance Graphics.Image.ColorSpace.ToYCbCr Graphics.Image.ColorSpace.CMYK.CMYK e => Graphics.Image.ColorSpace.ToYCbCrA Graphics.Image.ColorSpace.CMYK.CMYK e instance Graphics.Image.Interface.Elevator.Elevator e => Graphics.Image.ColorSpace.ToYCbCrA Graphics.Image.ColorSpace.CMYK.CMYKA e instance Graphics.Image.ColorSpace.ToYCbCr Graphics.Image.ColorSpace.YCbCr.YCbCr e => Graphics.Image.ColorSpace.ToYCbCrA Graphics.Image.ColorSpace.YCbCr.YCbCr e instance Graphics.Image.Interface.Elevator.Elevator e => Graphics.Image.ColorSpace.ToYCbCrA Graphics.Image.ColorSpace.YCbCr.YCbCrA e module Graphics.Image.Processing -- | Downsample an image by discarding every odd row. downsampleRows :: Array arr cs e => Image arr cs e -> Image arr cs e -- | Downsample an image by discarding every odd column. downsampleCols :: Array arr cs e => Image arr cs e -> Image arr cs e -- | Downsample an image. Drop all rows and colums that satisfy the -- predicates. For example, in order to discard every 5th row and keep -- every even indexed column: -- --
--   >>> frog <- readImageRGB RPU "images/frog.jpg"
--   
--   >>> displayImage $ downsample ((0 ==) . (`mod` 5)) odd frog
--   
-- downsample :: Array arr cs e => (Int -> Bool) -> (Int -> Bool) -> Image arr cs e -> Image arr cs e -- | Upsample an image by inserting a row of back pixels after each row of -- a source image. upsampleRows :: Array arr cs e => Image arr cs e -> Image arr cs e -- | Upsample an image by inserting a column of back pixels after each -- column of a source image. upsampleCols :: Array arr cs e => Image arr cs e -> Image arr cs e -- | Upsample an image by inserting rows and columns with zero valued -- pixels into an image. Supplied functions specify how many rows/columns -- shoud be inserted (before, after) a particular row/column. -- Returning a negative value in a tuple will result in an error. E.g. -- insert 2 columns before and 4 columns after every 10th column, while -- leaving rows count unchanged: -- --
--   >>> frog <- readImageRGB RPU "images/frog.jpg"
--   
--   >>> displayImage $ upsample (const (0, 0)) (\ k -> if k `mod` 10 == 0 then (2, 4) else (0, 0)) frog
--   
-- upsample :: Array arr cs e => (Int -> (Int, Int)) -> (Int -> (Int, Int)) -> Image arr cs e -> Image arr cs e -- | Concatenate two images together into one. Both input images must have -- the same number of rows. leftToRight :: Array arr cs e => Image arr cs e -> Image arr cs e -> Image arr cs e -- | Concatenate two images together into one. Both input images must have -- the same number of columns. topToBottom :: Array arr cs e => Image arr cs e -> Image arr cs e -> Image arr cs e -- | Shift an image towards its bottom right corner by (delatM, -- deltaN) rows and columns, while specifying a border resolution -- strategy. -- --
--   >>> frog <- readImageRGB VU "images/frog.jpg"
--   
--   >>> writeImage "images/frog_translate_wrap.jpg" $ translate Wrap (50, 100) frog
--   
--   >>> writeImage "images/frog_translate_edge.jpg" $ translate Edge (50, 100) frog
--   
-- translate :: Array arr cs e => Border (Pixel cs e) -> (Int, Int) -> Image arr cs e -> Image arr cs e -- | Change the size of an image. Pixel values and positions will not -- change, except the ones outside the border, which are handled -- according to supplied resolution strategy. -- -- -- For example, it can be used to make a tile from the image above, or -- simply scale the canvas and place it in a middle: -- --
--   >>> logo <- readImageRGBA VU "images/logo_40.png"
--   
--   >>> let incBy (fm, fn) = (rows logo * fm, cols logo * fn)
--   
--   >>> writeImage "images/logo_tile.png" $ canvasSize Wrap (incBy (6, 10)) logo
--   
--   >>> writeImage "images/logo_center.png" $ translate (Fill 0) (incBy (2, 3)) $ canvasSize (Fill 0) (incBy (5, 7)) logo
--   
-- canvasSize :: Array arr cs e => Border (Pixel cs e) -> (Int, Int) -> Image arr cs e -> Image arr cs e -- | Crop an image, i.e. retrieves a sub-image image with m rows -- and n columns. Make sure (i + m, j + n) is not -- greater than dimensions of a source image, otherwise it will result in -- an error. crop :: Array arr cs e => (Int, Int) -> (Int, Int) -> Image arr cs e -> Image arr cs e -- | Place one image on top of a source image, starting at a particular -- location within a source image. superimpose :: Array arr cs e => (Int, Int) -> Image arr cs e -> Image arr cs e -> Image arr cs e -- | Flip an image vertically. -- --
--   >>> frog <- readImageRGB VU "images/frog.jpg"
--   
--   >>> writeImage "images/frog_flipV.jpg" $ flipV frog
--   
-- flipV :: Array arr cs e => Image arr cs e -> Image arr cs e -- | Flip an image horizontally. -- --
--   >>> frog <- readImageRGB VU "images/frog.jpg"
--   
--   >>> writeImage "images/frog_flipH.jpg" $ flipH frog
--   
-- flipH :: Array arr cs e => Image arr cs e -> Image arr cs e -- | Rotate an image clockwise by 90°. -- --
--   >>> frog <- readImageRGB VU "images/frog.jpg"
--   
--   >>> writeImage "images/frog_rotate90.jpg" $ rotate90 frog
--   
-- rotate90 :: Array arr cs e => Image arr cs e -> Image arr cs e -- | Rotate an image by 180°. -- --
--   >>> frog <- readImageRGB VU "images/frog.jpg"
--   
--   >>> writeImage "images/frog_rotate180.jpg" $ rotate180 frog
--   
-- rotate180 :: Array arr cs e => Image arr cs e -> Image arr cs e -- | Rotate an image clockwise by 270°. -- --
--   >>> frog <- readImageRGB VU "images/frog.jpg"
--   
--   >>> writeImage "images/frog_rotate270.jpg" $ rotate270 frog
--   
-- rotate270 :: Array arr cs e => Image arr cs e -> Image arr cs e -- | Rotate an image clockwise by an angle Θ in radians. -- --
--   >>> frog <- readImageRGBA VU "images/frog.jpg"
--   
--   >>> writeImage "images/frog_rotate330.png" $ rotate Bilinear (Fill 0) (11*pi/6) frog
--   
-- rotate :: (Array arr cs e, Interpolation method) => method -> Border (Pixel cs e) -> Double -> Image arr cs e -> Image arr cs e -- | Resize an image using an interpolation method. -- --
--   >>> frog <- readImageRGB VU "images/frog.jpg"
--   
--   >>> writeImage "images/frog_resize.jpg" $ resize Bilinear Edge (100, 640) frog
--   
-- resize :: (Interpolation method, Array arr cs e) => method -> Border (Pixel cs e) -> (Int, Int) -> Image arr cs e -> Image arr cs e -- | Scale an image. Same as resize, except scaling factors are supplied -- instead of new dimensions. -- --
--   scale Bilinear Edge (0.5, 2) frog == resize Bilinear Edge (100, 640) frog
--   
scale :: (Interpolation method, Array arr cs e) => method -> Border (Pixel cs e) -> (Double, Double) -> Image arr cs e -> Image arr cs e -- | Implementation for an interpolation method. class Interpolation method -- | Construct a new pixel by using information from neighboring pixels. interpolate :: (Interpolation method, ColorSpace cs e) => method -> Border (Pixel cs e) -> (Int, Int) -> ((Int, Int) -> Pixel cs e) -> (Double, Double) -> Pixel cs e -- | Nearest Neighbor interpolation method. data Nearest Nearest :: Nearest -- | Bilinear interpolation method. data Bilinear Bilinear :: Bilinear -- | Convolution of an image using a kernel. Border resolution technique is -- required. -- -- Example using Sobel operator: -- --
--   >>> frog <- readImageY RPU "images/frog.jpg"
--   
--   >>> let frogX = convolve Edge (fromLists [[-1, 0, 1], [-2, 0, 2], [-1, 0, 1]]) frog
--   
--   >>> let frogY = convolve Edge (fromLists [[-1,-2,-1], [ 0, 0, 0], [ 1, 2, 1]]) frog
--   
--   >>> displayImage $ normalize $ sqrt (frogX ^ 2 + frogY ^ 2)
--   
-- convolve :: Array arr cs e => Border (Pixel cs e) -> Image arr cs e -> Image arr cs e -> Image arr cs e -- | Convolve image's rows with a vector kernel represented by a list of -- pixels. convolveRows :: Array arr cs e => Border (Pixel cs e) -> [Pixel cs e] -> Image arr cs e -> Image arr cs e -- | Convolve image's columns with a vector kernel represented by a list of -- pixels. convolveCols :: Array arr cs e => Border (Pixel cs e) -> [Pixel cs e] -> Image arr cs e -> Image arr cs e -- | Correlate an image with a kernel. Border resolution technique is -- required. correlate :: Array arr cs e => Border (Pixel cs e) -> Image arr cs e -> Image arr cs e -> Image arr cs e -- | Approach to be used near the borders during various transformations. -- Whenever a function needs information not only about a pixel of -- interest, but also about it's neighbours, it will go out of bounds -- around the image edges, hence is this set of approaches that can be -- used in such situtation. data Border px -- | Fill in a constant pixel. -- --
--              outside |  Image  | outside
--   (Fill 0) : 0 0 0 0 | 1 2 3 4 | 0 0 0 0
--   
Fill :: !px -> Border px -- | Wrap around from the opposite border of the image. -- --
--              outside |  Image  | outside
--   Wrap :     1 2 3 4 | 1 2 3 4 | 1 2 3 4
--   
Wrap :: Border px -- | Replicate the pixel at the edge. -- --
--              outside |  Image  | outside
--   Edge :     1 1 1 1 | 1 2 3 4 | 4 4 4 4
--   
Edge :: Border px -- | Mirror like reflection. -- --
--              outside |  Image  | outside
--   Reflect :  4 3 2 1 | 1 2 3 4 | 4 3 2 1
--   
Reflect :: Border px -- | Also mirror like reflection, but without repeating the edge pixel. -- --
--              outside |  Image  | outside
--   Continue : 1 4 3 2 | 1 2 3 4 | 3 2 1 4
--   
Continue :: Border px -- | This function magnifies an image by a positive factor and draws a grid -- around the original pixels. It is here simply as useful inspection -- tool. -- --
--   >>> frog <- readImageRGB VU "images/frog.jpg"
--   
--   >>> writeImage "images/frog_eye_grid.png" $ pixelGrid 10 $ crop (51, 112) (20, 20) frog
--   
-- pixelGrid :: Array arr cs e => Word8 -> Image arr cs e -> Image arr cs e module Graphics.Image.IO.Formats -- | Bitmap image with .bmp extension. data BMP BMP :: BMP -- | Graphics Interchange Format image with .gif extension. data GIF GIF :: GIF data GIFA GIFA :: GIFA -- | Delay to wait before showing the next Gif image. The delay is -- expressed in 100th of seconds. type GifDelay = Int -- | Help to control the behaviour of GIF animation looping. data GifLooping :: * -- | The animation will stop once the end is reached LoopingNever :: GifLooping -- | The animation will restart once the end is reached LoopingForever :: GifLooping -- | The animation will repeat n times before stoping LoopingRepeat :: Word16 -> GifLooping -- | To specify how the palette will be created. data PaletteOptions :: * PaletteOptions :: PaletteCreationMethod -> Bool -> Int -> PaletteOptions -- | Algorithm used to find the palette [paletteCreationMethod] :: PaletteOptions -> PaletteCreationMethod -- | Do we want to apply the dithering to the image. Enabling it often -- reduce compression ratio but enhance the perceived quality of the -- final image. [enableImageDithering] :: PaletteOptions -> Bool -- | Maximum number of color we want in the palette [paletteColorCount] :: PaletteOptions -> Int -- | Define which palette creation method is used. data PaletteCreationMethod :: * -- | MedianMeanCut method, provide the best results (visualy) at the cost -- of increased calculations. MedianMeanCut :: PaletteCreationMethod -- | Very fast algorithm (one pass), doesn't provide good looking results. Uniform :: PaletteCreationMethod -- | High-dynamic-range image with .hdr or .pic -- extension. data HDR HDR :: HDR -- | Joint Photographic Experts Group image with .jpg or -- .jpeg extension. data JPG JPG :: JPG -- | Portable Network Graphics image with .png extension. data PNG PNG :: PNG -- | Truevision Graphics Adapter image with .tga extension. data TGA TGA :: TGA -- | Tagged Image File Format image with .tif or .tiff -- extension. data TIF TIF :: TIF -- | Netpbm: portable bitmap image with .pbm extension. data PBM PBM :: PBM -- | Netpbm: portable graymap image with .pgm extension. data PGM PGM :: PGM -- | Netpbm: portable pixmap image with .ppm extension. data PPM PPM :: PPM -- | A collection of all image formats that can be read into HIP images. data InputFormat InputBMP :: InputFormat InputGIF :: InputFormat InputHDR :: InputFormat InputJPG :: InputFormat InputPNG :: InputFormat InputTIF :: InputFormat InputPNM :: InputFormat InputTGA :: InputFormat -- | A collection of all image formats that can be written to file using -- images with Double precision pixels. data OutputFormat OutputBMP :: OutputFormat OutputGIF :: OutputFormat OutputHDR :: OutputFormat OutputJPG :: OutputFormat OutputPNG :: OutputFormat OutputTIF :: OutputFormat OutputTGA :: OutputFormat -- | Image formats that can be read from file. class ImageFormat format => Readable img format -- | Decode an image from ByteString. decode :: Readable img format => format -> ByteString -> Either String img -- | Image formats that can be written to file. class ImageFormat format => Writable img format -- | Encode an image to ByteString. encode :: Writable img format => format -> [SaveOption format] -> img -> ByteString -- | Image file format. Helps in guessing image format using a file -- extension, as well as supplying format specific options during saving -- an image. class ImageFormat format where data SaveOption format exts f = [ext f] isFormat e f = e `elem` exts f where { data family SaveOption format; } -- | Default file extension for this image format. ext :: ImageFormat format => format -> String -- | Known extensions for this image format. exts :: ImageFormat format => format -> [String] -- | Returns True if a file extension (ex. ".png") -- corresponds to this format. isFormat :: ImageFormat format => String -> format -> Bool -- | Used during converting pixels between libraries. class Convertible a b convert :: Convertible a b => a -> b instance GHC.Enum.Bounded Graphics.Image.IO.Formats.OutputFormat instance GHC.Enum.Enum Graphics.Image.IO.Formats.OutputFormat instance GHC.Show.Show Graphics.Image.IO.Formats.OutputFormat instance GHC.Classes.Eq Graphics.Image.IO.Formats.OutputFormat instance GHC.Enum.Bounded Graphics.Image.IO.Formats.InputFormat instance GHC.Enum.Enum Graphics.Image.IO.Formats.InputFormat instance GHC.Show.Show Graphics.Image.IO.Formats.InputFormat instance GHC.Classes.Eq Graphics.Image.IO.Formats.InputFormat instance Graphics.Image.IO.Base.ImageFormat Graphics.Image.IO.Formats.InputFormat instance (Graphics.Image.IO.Base.Readable (Graphics.Image.Interface.Image arr cs GHC.Types.Double) Graphics.Image.IO.Formats.JuicyPixels.Common.BMP, Graphics.Image.IO.Base.Readable (Graphics.Image.Interface.Image arr cs GHC.Types.Double) Graphics.Image.IO.Formats.JuicyPixels.Common.GIF, Graphics.Image.IO.Base.Readable (Graphics.Image.Interface.Image arr cs GHC.Types.Double) Graphics.Image.IO.Formats.JuicyPixels.Common.HDR, Graphics.Image.IO.Base.Readable (Graphics.Image.Interface.Image arr cs GHC.Types.Double) Graphics.Image.IO.Formats.JuicyPixels.Common.JPG, Graphics.Image.IO.Base.Readable (Graphics.Image.Interface.Image arr cs GHC.Types.Double) Graphics.Image.IO.Formats.JuicyPixels.Common.PNG, Graphics.Image.IO.Base.Readable (Graphics.Image.Interface.Image arr cs GHC.Types.Double) Graphics.Image.IO.Formats.JuicyPixels.Common.TGA, Graphics.Image.IO.Base.Readable (Graphics.Image.Interface.Image arr cs GHC.Types.Double) Graphics.Image.IO.Formats.JuicyPixels.Common.TIF, Graphics.Image.IO.Base.Readable (Graphics.Image.Interface.Image arr cs GHC.Types.Double) Graphics.Image.IO.Formats.Netpbm.PPM) => Graphics.Image.IO.Base.Readable (Graphics.Image.Interface.Image arr cs GHC.Types.Double) Graphics.Image.IO.Formats.InputFormat instance Graphics.Image.IO.Base.ImageFormat Graphics.Image.IO.Formats.OutputFormat instance (Graphics.Image.IO.Base.Writable (Graphics.Image.Interface.Image arr cs GHC.Types.Double) Graphics.Image.IO.Formats.JuicyPixels.Common.BMP, Graphics.Image.IO.Base.Writable (Graphics.Image.Interface.Image arr cs GHC.Types.Double) Graphics.Image.IO.Formats.JuicyPixels.Common.GIF, Graphics.Image.IO.Base.Writable (Graphics.Image.Interface.Image arr cs GHC.Types.Double) Graphics.Image.IO.Formats.JuicyPixels.Common.HDR, Graphics.Image.IO.Base.Writable (Graphics.Image.Interface.Image arr cs GHC.Types.Double) Graphics.Image.IO.Formats.JuicyPixels.Common.JPG, Graphics.Image.IO.Base.Writable (Graphics.Image.Interface.Image arr cs GHC.Types.Double) Graphics.Image.IO.Formats.JuicyPixels.Common.PNG, Graphics.Image.IO.Base.Writable (Graphics.Image.Interface.Image arr cs GHC.Types.Double) Graphics.Image.IO.Formats.JuicyPixels.Common.TGA, Graphics.Image.IO.Base.Writable (Graphics.Image.Interface.Image arr cs GHC.Types.Double) Graphics.Image.IO.Formats.JuicyPixels.Common.TIF) => Graphics.Image.IO.Base.Writable (Graphics.Image.Interface.Image arr cs GHC.Types.Double) Graphics.Image.IO.Formats.OutputFormat instance (Graphics.Image.Interface.Array arr cs e, Graphics.Image.Interface.Array arr cs (Data.Complex.Complex e), GHC.Float.RealFloat e, GHC.Base.Applicative (Graphics.Image.Interface.Pixel cs), Graphics.Image.IO.Base.Writable (Graphics.Image.Interface.Image arr cs e) format) => Graphics.Image.IO.Base.Writable (Graphics.Image.Interface.Image arr cs (Data.Complex.Complex e)) format module Graphics.Image.IO -- | This function will try to guess an image format from file's extension, -- then it will attempt to decode it as such. It will fall back onto the -- rest of the supported formats and will try to read them regarless of -- file's extension. Whenever image cannot be decoded, Left -- containing all errors for each attempted format will be returned, and -- Right containing an image otherwise. Image will be read with a -- type signature specified: -- --
--   >>> frog <- readImage "images/frog.jpg" :: IO (Either String (Image VS RGB Word8))
--   
--   >>> displayImage frog
--   
readImage :: forall arr cs e. (Array VS cs e, Array arr cs e, Readable (Image VS cs e) InputFormat) => FilePath -> IO (Either String (Image arr cs e)) -- | Just like readImage, but will throw an exception if incorrect -- format is detected. readImage' :: (Array VS cs e, Array arr cs e, Readable (Image VS cs e) InputFormat) => FilePath -> IO (Image arr cs e) -- | This function allows for reading all supported image in their exact -- colorspace and precision. Only VS image representation can be -- read natively, but exchange can be use later to switch to a -- different representation. For instance, "frog.jpg" image can be read -- into it's YCbCr colorspace with Word8 precision: -- --
--   >>> readImageExact JPG "images/frog.jpg" :: IO (Either String (Image VS YCbCr Word8))
--   Right <Image VS YCbCr (Word8): 200x320>
--   
-- -- The drawback here is that colorspace and precision has to match -- exactly, otherwise it will return an error: -- --
--   >>> readImageExact JPG "images/frog.jpg" :: IO (Either String (Image VS RGB Word8))
--   Left "JuicyPixel decoding error: Input image is in YCbCr8 (Pixel YCbCr Word8), cannot convert it to RGB8 (Pixel RGB Word8) colorspace."
--   
-- -- Any attempt to read an image in a color space, which is not supported -- by supplied format, will result in a compile error. Refer to -- Readable class for all images that can be decoded. readImageExact :: Readable img format => format -> FilePath -> IO (Either String img) -- | Just like readImageExact, but will throw an exception if -- incorrect format is detected. readImageExact' :: Readable b format => format -> FilePath -> IO b -- | Just like readImage, this function will guess an output file -- format from the extension and write to file any image that is in one -- of Y, YA, RGB or RGBA color spaces with -- Double precision. While doing necessary conversions the choice -- will be given to the most suited color space supported by the format. -- For instance, in case of a PNG format, an (Image -- arr RGBA Double) would be written as -- RGBA16, hence preserving transparency and using highest -- supported precision Word16. At the same time, writing that -- image in GIF format would save it in RGB8, since -- Word8 is the highest precision GIF supports and it -- currently cannot be saved with transparency. writeImage :: (Array VS cs e, Array arr cs e, Writable (Image VS cs e) OutputFormat) => FilePath -> Image arr cs e -> IO () -- | Write an image in a specific format, while supplying any format -- specific options. Precision and color space, that an image will be -- written as, is decided from image's type. Attempt to write image file -- in a format that does not support color space and precision -- combination will result in a compile error. writeImageExact :: Writable img format => format -> [SaveOption format] -> FilePath -> img -> IO () -- | External viewing application to use for displaying images. data ExternalViewer -- | Any custom viewer, which can be specified: -- -- ExternalViewer :: FilePath -> [String] -> Int -> ExternalViewer -- | Makes a call to an external viewer that is set as a default image -- viewer by the OS. This is a non-blocking function call, so it might -- take some time before an image will appear. displayImage :: (Array VS cs e, Array arr cs e, Writable (Image VS cs e) TIF) => Image arr cs e -> IO () -- | An image is written as a .tiff file into an operating -- system's temporary directory and passed as an argument to the external -- viewer program. displayImageUsing :: (Array VS cs e, Array arr cs e, Writable (Image VS cs e) TIF) => ExternalViewer -> Bool -> Image arr cs e -> IO () -- | Displays an image file by calling an external image viewer. displayImageFile :: ExternalViewer -> FilePath -> IO () -- | Default viewer is inferred from the operating system. defaultViewer :: ExternalViewer -- |
--   eog /tmp/hip/img.tiff
--   
-- -- Eye of GNOME eogViewer :: ExternalViewer -- |
--   gpicview /tmp/hip/img.tiff
--   
-- -- GPicView gpicviewViewer :: ExternalViewer -- |
--   feh --fullscreen --auto-zoom /tmp/hip/img.tiff
--   
-- -- FEH fehViewer :: ExternalViewer -- |
--   gimp /tmp/hip/img.tiff
--   
-- -- GIMP gimpViewer :: ExternalViewer instance GHC.Show.Show Graphics.Image.IO.ExternalViewer module Graphics.Image.IO.Histogram -- | A single channel histogram of an image. data Histogram Histogram :: Vector Int -> String -> AlphaColour Double -> Histogram -- | Vector containing pixel counts. Index of a vector serves as an -- original pixel value. [hBins] :: Histogram -> Vector Int -- | Name of the channel that will be displayed in the legend. [hName] :: Histogram -> String -- | Color of a plotted line. [hColour] :: Histogram -> AlphaColour Double -- | For now it is just a type synonym, but in the future it might become a -- custom data type with fields like title, width, heigth, etc. type Histograms = [Histogram] class ChannelColour cs -- | Get a pure colour representation of a channel. csColour :: ChannelColour cs => cs -> AlphaColour Double -- | Create a histogram per channel with 256 bins each. getHistograms :: forall arr cs e. (ChannelColour cs, MArray arr X e, Array arr X e, MArray arr cs e, Array arr cs e) => Image arr cs e -> Histograms -- | Generate a histogram with 256 bins for a single channel Gray image. getHistogram :: MArray arr X e => Image arr X e -> Histogram -- | Display image histograms using an external program. Works in a similar -- way as displayImage. -- --
--   >>> frog <- readImageRGB VU "images/frog.jpg"
--   
--   >>> displayHistograms $ getHistograms frog
--   
displayHistograms :: Histograms -> IO () -- | Write histograms into a PNG image file. -- --
--   >>> frog <- readImageRGB VU "images/frog.jpg"
--   
--   >>> writeHistograms "images/frog_histogram.svg" $ getHistograms frog
--   
-- writeHistograms :: FilePath -> Histograms -> IO () instance Graphics.Image.IO.Histogram.ChannelColour Graphics.Image.ColorSpace.X.X instance Graphics.Image.IO.Histogram.ChannelColour Graphics.Image.ColorSpace.Y.Y instance Graphics.Image.IO.Histogram.ChannelColour Graphics.Image.ColorSpace.Y.YA instance Graphics.Image.IO.Histogram.ChannelColour Graphics.Image.ColorSpace.RGB.RGB instance Graphics.Image.IO.Histogram.ChannelColour Graphics.Image.ColorSpace.RGB.RGBA instance Graphics.Image.IO.Histogram.ChannelColour Graphics.Image.ColorSpace.HSI.HSI instance Graphics.Image.IO.Histogram.ChannelColour Graphics.Image.ColorSpace.HSI.HSIA instance Graphics.Image.IO.Histogram.ChannelColour Graphics.Image.ColorSpace.CMYK.CMYK instance Graphics.Image.IO.Histogram.ChannelColour Graphics.Image.ColorSpace.CMYK.CMYKA instance Graphics.Image.IO.Histogram.ChannelColour Graphics.Image.ColorSpace.YCbCr.YCbCr instance Graphics.Image.IO.Histogram.ChannelColour Graphics.Image.ColorSpace.YCbCr.YCbCrA module Graphics.Image.Processing.Binary -- | Construct a binary image using a predicate from a source image. toImageBinaryUsing :: (Array arr cs e, Array arr Binary Bit) => (Pixel cs e -> Bool) -> Image arr cs e -> Image arr Binary Bit -- | Construct a binary image using a predicate from two source images. toImageBinaryUsing2 :: (Array arr cs e, Array arr Binary Bit) => (Pixel cs e -> Pixel cs e -> Bool) -> Image arr cs e -> Image arr cs e -> Image arr Binary Bit -- | Threshold a source image with an applicative pixel. -- --
--   >>> yield <- readImageRGB VU "images/yield.jpg"
--   
--   >>> writeImageExact PNG [] "images/yield_bin.png" $ thresholdWith (PixelRGB (>0.55) (<0.6) (<0.5)) yield
--   
-- thresholdWith :: (Applicative (Pixel cs), Foldable (Pixel cs), Array arr cs e, Array arr Binary Bit) => Pixel cs (e -> Bool) -> Image arr cs e -> Image arr Binary Bit -- | Compare two images with an applicative pixel. Works just like -- thresholdWith, but on two images. compareWith :: (Applicative (Pixel cs), Foldable (Pixel cs), Array arr cs e1, Array arr cs e2, Array arr Binary Bit) => Pixel cs (e1 -> e2 -> Bool) -> Image arr cs e1 -> Image arr cs e2 -> Image arr Binary Bit -- | Disjunction of all pixels in a Binary image or :: Array arr Binary Bit => Image arr Binary Bit -> Bool -- | Conjunction of all pixels in a Binary image and :: Array arr Binary Bit => Image arr Binary Bit -> Bool -- | Pixel wise AND operator on binary images. (.&&.) :: Array arr Binary Bit => Image arr Binary Bit -> Image arr Binary Bit -> Image arr Binary Bit infixr 3 .&&. -- | Pixel wise OR operator on binary images. (.||.) :: Array arr Binary Bit => Image arr Binary Bit -> Image arr Binary Bit -> Image arr Binary Bit infixr 2 .||. -- | Complement each pixel in a binary image invert :: Array arr Binary Bit => Image arr Binary Bit -> Image arr Binary Bit -- | Thresholding contains a convenient set of functions for binary -- image construction, which is done by comparing either a single pixel -- with every pixel in an image or two same size images pointwise. For -- example: -- --
--   >>> frog <- readImageY VU "images/frog.jpg"
--   
--   >>> frog .==. PixelY 0    -- (or: PixelY 0 .==. frog)
--   
--   >>> frog .<. flipH frog   -- (or: flipH frog .>. frog)
--   
class Array arr Binary Bit => Thresholding a b arr | a b -> arr (.==.) :: (Thresholding a b arr, Array arr cs e) => a cs e -> b cs e -> Image arr Binary Bit (./=.) :: (Thresholding a b arr, Array arr cs e) => a cs e -> b cs e -> Image arr Binary Bit (.<.) :: (Thresholding a b arr, Ord (Pixel cs e), Array arr cs e) => a cs e -> b cs e -> Image arr Binary Bit (.<=.) :: (Thresholding a b arr, Ord (Pixel cs e), Array arr cs e) => a cs e -> b cs e -> Image arr Binary Bit (.>.) :: (Thresholding a b arr, Ord (Pixel cs e), Array arr cs e) => a cs e -> b cs e -> Image arr Binary Bit (.>=.) :: (Thresholding a b arr, Ord (Pixel cs e), Array arr cs e) => a cs e -> b cs e -> Image arr Binary Bit -- | Erosion is defined as: {E = B ⊖ S = {m,n|Sₘₙ⊆B} -- --
--   >>> writeImageExact PNG [] "images/figure_erode.png" $ pixelGrid 10 $ fromImageBinary $ erode struct figure
--   
-- -- eroded with is erode :: Array arr Binary Bit => Image arr Binary Bit -> Image arr Binary Bit -> Image arr Binary Bit -- | Dialation is defined as: {D = B ⊕ S = {m,n|Sₘₙ∩B≠∅} -- --
--   >>> writeImageExact PNG [] "images/figure_dialate.png" $ pixelGrid 10 $ fromImageBinary $ dialate struct figure
--   
-- -- dialated with is dialate :: Array arr Binary Bit => Image arr Binary Bit -> Image arr Binary Bit -> Image arr Binary Bit -- | Opening is defined as: {B ○ S = (B ⊖ S) ⊕ S} -- --
--   >>> writeImageExact PNG [] "images/figure_open.png" $ pixelGrid 10 $ fromImageBinary $ open struct figure
--   
-- -- opened with is open :: Array arr Binary Bit => Image arr Binary Bit -> Image arr Binary Bit -> Image arr Binary Bit -- | Closing is defined as: {B ● S = (B ⊕ S) ⊖ S} -- --
--   >>> writeImageExact PNG [] "images/figure_close.png" $ pixelGrid 10 $ fromImageBinary $ close struct figure
--   
-- -- closed with is close :: Array arr Binary Bit => Image arr Binary Bit -> Image arr Binary Bit -> Image arr Binary Bit instance Graphics.Image.Interface.Array arr Graphics.Image.ColorSpace.Binary.Binary Graphics.Image.ColorSpace.Binary.Bit => Graphics.Image.Processing.Binary.Thresholding (Graphics.Image.Interface.Image arr) (Graphics.Image.Interface.Image arr) arr instance Graphics.Image.Interface.Array arr Graphics.Image.ColorSpace.Binary.Binary Graphics.Image.ColorSpace.Binary.Bit => Graphics.Image.Processing.Binary.Thresholding Graphics.Image.Interface.Pixel (Graphics.Image.Interface.Image arr) arr instance Graphics.Image.Interface.Array arr Graphics.Image.ColorSpace.Binary.Binary Graphics.Image.ColorSpace.Binary.Bit => Graphics.Image.Processing.Binary.Thresholding (Graphics.Image.Interface.Image arr) Graphics.Image.Interface.Pixel arr module Graphics.Image.Types class (Vector (Vector arr) (Pixel cs e), MArray (Manifest arr) cs e, BaseArray arr cs e) => Array arr cs e -- | Array representation that is actually has real data stored in memory, -- hence allowing for image indexing, forcing pixels into computed state -- etc. class BaseArray arr cs e => MArray arr cs e where data MImage s arr cs e index !img !ix = borderIndex (error $ show img ++ " - Index out of bounds: " ++ show ix) img ix where { data family MImage s arr cs e; } -- | Approach to be used near the borders during various transformations. -- Whenever a function needs information not only about a pixel of -- interest, but also about it's neighbours, it will go out of bounds -- around the image edges, hence is this set of approaches that can be -- used in such situtation. data Border px -- | Fill in a constant pixel. -- --
--              outside |  Image  | outside
--   (Fill 0) : 0 0 0 0 | 1 2 3 4 | 0 0 0 0
--   
Fill :: !px -> Border px -- | Wrap around from the opposite border of the image. -- --
--              outside |  Image  | outside
--   Wrap :     1 2 3 4 | 1 2 3 4 | 1 2 3 4
--   
Wrap :: Border px -- | Replicate the pixel at the edge. -- --
--              outside |  Image  | outside
--   Edge :     1 1 1 1 | 1 2 3 4 | 4 4 4 4
--   
Edge :: Border px -- | Mirror like reflection. -- --
--              outside |  Image  | outside
--   Reflect :  4 3 2 1 | 1 2 3 4 | 4 3 2 1
--   
Reflect :: Border px -- | Also mirror like reflection, but without repeating the edge pixel. -- --
--              outside |  Image  | outside
--   Continue : 1 4 3 2 | 1 2 3 4 | 3 2 1 4
--   
Continue :: Border px -- | Unboxed Vector representation. data VU VU :: VU -- | Storable Vector representation. data VS VS :: VS -- | Repa Array representation backed by Unboxed Vector, which is computed -- sequentially. data RSU RSU :: RSU -- | Repa Array representation backed by Unboxed Vector, which is computed -- in parallel. data RPU RPU :: RPU -- | Repa Array representation backed by Storable Vector, which is computed -- sequentially. data RSS RSS :: RSS -- | Repa Array representation backed by Storable Vector, which is computed -- in parallel. data RPS RPS :: RPS -- | Haskell Image Processing (HIP) library is a wrapper around any array -- like data structure and is fully agnostic to the underlying -- representation. All of the functionality in this library relies upon a -- few type classes, which corresponding representation types are -- instances of: -- -- -- -- Representations using Vector and Repa packages: -- -- -- -- Images with RSU, RSS, RPU and RPS types, -- most of the time, hold functions rather than an actual data, this way -- computation can be fused together, and later changed to VU or -- VS using toManifest, which in turn performs the fused -- computation. If at any time computation needs to be forced, -- compute can be used for that purpose. -- -- Many of the function names exported by this module will clash with the -- ones from Prelude, hence it can be more convenient to import -- like this: -- --
--   import Prelude as P
--   import Graphics.Image as I
--   
module Graphics.Image -- | Create an image with a specified representation and pixels of -- Double precision. Note, that it is essential for Double -- precision pixels to keep values normalized in the [0, 1] -- range in order for an image to be written to file properly. -- --
--   >>> let grad_gray = makeImageR VU (200, 200) (\(i, j) -> PixelY (fromIntegral i) / 200 * (fromIntegral j) / 200)
--   
-- -- Because all Pixels and Images are installed into -- Num, above is equivalent to: -- --
--   >>> let grad_gray = makeImageR RPU (200, 200) (\(i, j) -> PixelY $ fromIntegral (i*j)) / (200*200)
--   
--   >>> writeImage "images/grad_gray.png" grad_gray
--   
-- -- Creating color images is just as easy. -- --
--   >>> let grad_color = makeImageR VU (200, 200) (\(i, j) -> PixelRGB (fromIntegral i) (fromIntegral j) (fromIntegral (i + j))) / 400
--   
--   >>> writeImage "images/grad_color.png" grad_color
--   
-- makeImageR :: Array arr cs Double => arr -> (Int, Int) -> ((Int, Int) -> Pixel cs Double) -> Image arr cs Double -- | Create an Image by supplying it's dimensions and a pixel generating -- function. makeImage :: Array arr cs e => (Int, Int) -> ((Int, Int) -> Pixel cs e) -> Image arr cs e -- | Type restricted version of fromLists that constructs an image -- using supplied representation. fromListsR :: Array arr cs e => arr -> [[Pixel cs e]] -> Image arr cs e -- | Construct an image from a nested rectangular shaped list of pixels. -- Length of an outer list will constitute m rows, while the -- length of inner lists - n columns. All of the inner lists -- must be the same length and greater than 0. -- --
--   >>> fromLists [[PixelY (fromIntegral (i*j) / 60000) | j <- [1..300]] | i <- [1..200]]
--   <Image VectorUnboxed Y (Double): 200x300>
--   
-- fromLists :: Array arr cs e => [[Pixel cs e]] -> Image arr cs e -- | Generates a nested list of pixels from an image. -- --
--   img == fromLists (toLists img)
--   
toLists :: MArray arr cs e => Image arr cs e -> [[Pixel cs e]] -- | Read image as luma (brightness). readImageY :: Array arr Y Double => arr -> FilePath -> IO (Image arr Y Double) -- | Read image as luma with Alpha channel. readImageYA :: Array arr YA Double => arr -> FilePath -> IO (Image arr YA Double) -- | Read image in RGB colorspace. readImageRGB :: Array arr RGB Double => arr -> FilePath -> IO (Image arr RGB Double) -- | Read image in RGB colorspace with Alpha channel. readImageRGBA :: Array arr RGBA Double => arr -> FilePath -> IO (Image arr RGBA Double) -- | Just like readImage, this function will guess an output file -- format from the extension and write to file any image that is in one -- of Y, YA, RGB or RGBA color spaces with -- Double precision. While doing necessary conversions the choice -- will be given to the most suited color space supported by the format. -- For instance, in case of a PNG format, an (Image -- arr RGBA Double) would be written as -- RGBA16, hence preserving transparency and using highest -- supported precision Word16. At the same time, writing that -- image in GIF format would save it in RGB8, since -- Word8 is the highest precision GIF supports and it -- currently cannot be saved with transparency. writeImage :: (Array VS cs e, Array arr cs e, Writable (Image VS cs e) OutputFormat) => FilePath -> Image arr cs e -> IO () -- | Makes a call to an external viewer that is set as a default image -- viewer by the OS. This is a non-blocking function call, so it might -- take some time before an image will appear. displayImage :: (Array VS cs e, Array arr cs e, Writable (Image VS cs e) TIF) => Image arr cs e -> IO () -- | Get the number of rows in an image. -- --
--   >>> frog <- readImageRGB VU "images/frog.jpg"
--   
--   >>> frog
--   <Image VectorUnboxed RGB (Double): 200x320>
--   
--   >>> rows frog
--   200
--   
rows :: BaseArray arr cs e => Image arr cs e -> Int -- | Get the number of columns in an image. -- --
--   >>> frog <- readImageRGB VU "images/frog.jpg"
--   
--   >>> frog
--   <Image VectorUnboxed RGB (Double): 200x320>
--   
--   >>> cols frog
--   320
--   
cols :: BaseArray arr cs e => Image arr cs e -> Int -- | Get dimensions of an image. -- --
--   >>> frog <- readImageRGB VU "images/frog.jpg"
--   
--   >>> frog
--   <Image VectorUnboxed RGB (Double): 200x320>
--   
--   >>> dims frog
--   (200,320)
--   
dims :: BaseArray arr cs e => Image arr cs e -> (Int, Int) -- | Get a pixel at i-th and j-th location. -- --
--   >>> let grad_gray = makeImage (200, 200) (\(i, j) -> PixelY $ fromIntegral (i*j)) / (200*200)
--   
--   >>> index grad_gray (20, 30) == PixelY ((20*30) / (200*200))
--   True
--   
index :: MArray arr cs e => Image arr cs e -> (Int, Int) -> Pixel cs e -- | Image indexing function that returns Nothing if index -- is out of bounds, Just px otherwise. maybeIndex :: MArray arr cs e => Image arr cs e -> (Int, Int) -> Maybe (Pixel cs e) -- | Image indexing function that returns a default pixel if index is out -- of bounds. defaultIndex :: MArray arr cs e => Pixel cs e -> Image arr cs e -> (Int, Int) -> Pixel cs e -- | Image indexing function that uses a special border resolutions -- strategy for out of bounds pixels. borderIndex :: MArray arr cs e => Border (Pixel cs e) -> Image arr cs e -> (Int, Int) -> Pixel cs e -- | Map a function over a an image. map :: (Array arr cs e, Array arr cs' e') => (Pixel cs' e' -> Pixel cs e) -> Image arr cs' e' -> Image arr cs e -- | Map an index aware function over each pixel in an image. imap :: (Array arr cs e, Array arr cs' e') => ((Int, Int) -> Pixel cs' e' -> Pixel cs e) -> Image arr cs' e' -> Image arr cs e -- | Zip two images with a function zipWith :: (Array arr cs e, Array arr cs1 e1, Array arr cs2 e2) => (Pixel cs1 e1 -> Pixel cs2 e2 -> Pixel cs e) -> Image arr cs1 e1 -> Image arr cs2 e2 -> Image arr cs e -- | Zip two images with an index aware function izipWith :: (Array arr cs e, Array arr cs1 e1, Array arr cs2 e2) => ((Int, Int) -> Pixel cs1 e1 -> Pixel cs2 e2 -> Pixel cs e) -> Image arr cs1 e1 -> Image arr cs2 e2 -> Image arr cs e -- | Traverse an image traverse :: (Array arr cs e, Array arr cs' e') => Image arr cs' e' -> ((Int, Int) -> (Int, Int)) -> (((Int, Int) -> Pixel cs' e') -> (Int, Int) -> Pixel cs e) -> Image arr cs e -- | Traverse two images. traverse2 :: (Array arr cs e, Array arr cs1 e1, Array arr cs2 e2) => Image arr cs1 e1 -> Image arr cs2 e2 -> ((Int, Int) -> (Int, Int) -> (Int, Int)) -> (((Int, Int) -> Pixel cs1 e1) -> ((Int, Int) -> Pixel cs2 e2) -> (Int, Int) -> Pixel cs e) -> Image arr cs e -- | Transpose an image transpose :: Array arr cs e => Image arr cs e -> Image arr cs e -- | Backwards permutation of an image. backpermute :: Array arr cs e => (Int, Int) -> ((Int, Int) -> (Int, Int)) -> Image arr cs e -> Image arr cs e -- | Perform matrix multiplication on two images. Inner dimensions must -- agree. (|*|) :: Array arr cs e => Image arr cs e -> Image arr cs e -> Image arr cs e -- | Undirected reduction of an image. fold :: Array arr cs e => (Pixel cs e -> Pixel cs e -> Pixel cs e) -> Pixel cs e -> Image arr cs e -> Pixel cs e -- | Sum all pixels in the image. sum :: Array arr cs e => Image arr cs e -> Pixel cs e -- | Multiply all pixels in the image. product :: Array arr cs e => Image arr cs e -> Pixel cs e -- | Retrieve the biggest pixel from an image maximum :: (Array arr cs e, Ord (Pixel cs e)) => Image arr cs e -> Pixel cs e -- | Retrieve the smallest pixel from an image minimum :: (Array arr cs e, Ord (Pixel cs e)) => Image arr cs e -> Pixel cs e -- | Scales all of the pixels to be in the range [0, 1]. normalize :: (Array arr cs e, Array arr X e, Fractional e, Ord e) => Image arr cs e -> Image arr cs e -- | Check weather two images are equal within a tolerance. Useful for -- comparing images with Float or Double precision. eqTol :: (Array arr Binary Bit, Array arr cs e, Ord e) => e -> Image arr cs e -> Image arr cs e -> Bool -- | Exchange the underlying array representation of an image. exchange :: (Array arr' cs e, Array arr cs e) => arr -> Image arr' cs e -> Image arr cs e