-- 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 <a>repa</a> and <a>vector</a>
--   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 <a>JuciyPixels</a> and <a>netpbm</a> 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.3.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, Eq (Pixel cs e), Unbox (Components cs e), Elevator 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

-- | Left fold on two pixels a the same time.
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.
--   
--   <pre>
--   addAlpha 0 (PixelHSI 1 2 3) == PixelHSIA 1 2 3 0
--   </pre>
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.
--   
--   <pre>
--   dropAlpha (PixelRGBA 1 2 3 4) == PixelRGB 1 2 3
--   </pre>
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.
--   
--   <pre>
--   &gt;&gt;&gt; let rgb = PixelRGB 0.0 0.5 1.0 :: Pixel RGB Double
--   
--   &gt;&gt;&gt; toWord8 &lt;$&gt; rgb
--   &lt;RGB:(0|128|255)&gt;
--   
--   &gt;&gt;&gt; toWord16 &lt;$&gt; rgb
--   &lt;RGB:(0|32768|65535)&gt;
--   </pre>
class (Eq e, Num e, Typeable e, Unbox e) => Elevator e

-- | Values are scaled to <tt>[0, 255]</tt> range.
toWord8 :: Elevator e => e -> Word8

-- | Values are scaled to <tt>[0, 65535]</tt> range.
toWord16 :: Elevator e => e -> Word16

-- | Values are scaled to <tt>[0, 4294967295]</tt> range.
toWord32 :: Elevator e => e -> Word32

-- | Values are scaled to <tt>[0, 18446744073709551615]</tt> range.
toWord64 :: Elevator e => e -> Word64

-- | Values are scaled to <tt>[0.0, 1.0]</tt> range.
toFloat :: Elevator e => e -> Float

-- | Values are scaled to <tt>[0.0, 1.0]</tt> range.
toDouble :: Elevator e => e -> Double

-- | Values are scaled from <tt>[0.0, 1.0]</tt> 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.
--   
--   <pre>
--   &gt;&gt;&gt; frog &lt;- readImageRGB VU "images/frog.jpg"
--   
--   &gt;&gt;&gt; frog
--   &lt;Image VectorUnboxed RGB (Double): 200x320&gt;
--   
--   &gt;&gt;&gt; dims frog
--   (200,320)
--   </pre>
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 <tt>(0, 0)</tt> index. Useful together with
--   <a>fold</a>, 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 <tt>m</tt> rows, while the
--   length of inner lists - <tt>n</tt> columns. All of the inner lists
--   must be the same length and greater than <tt>0</tt>.
--   
--   <pre>
--   &gt;&gt;&gt; fromLists [[PixelY (fromIntegral (i*j) / 60000) | j &lt;- [1..300]] | i &lt;- [1..200]]
--   &lt;Image VectorUnboxed Y (Double): 200x300&gt;
--   </pre>
--   
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 <a>Eq</a> typeclass.
eq :: Array arr cs e => Image arr cs e -> Image arr cs e -> Bool

-- | <a>Array</a> 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 <a>Manifest</a> array representation, which
toManifest :: Array arr cs e => Image arr cs e -> Image (Manifest arr) cs e

-- | Convert an image to a flattened <a>Vector</a>. For all current
--   representations it is a <b>O(1)</b> opeartion.
--   
--   <pre>
--   &gt;&gt;&gt; toVector $ makeImage (3, 2) (\(i, j) -&gt; PixelY $ fromIntegral (i+j))
--   fromList [&lt;Luma:(0.0)&gt;,&lt;Luma:(1.0)&gt;,&lt;Luma:(1.0)&gt;,&lt;Luma:(2.0)&gt;,&lt;Luma:(2.0)&gt;,&lt;Luma:(3.0)&gt;]
--   </pre>
toVector :: Array arr cs e => Image arr cs e -> Vector arr (Pixel cs e)

-- | Construct a two dimensional image with <tt>m</tt> rows and <tt>n</tt>
--   columns from a flat <a>Vector</a> of length <tt>k</tt>. For all
--   current representations it is a <b>O(1)</b> opeartion. Make sure that
--   <tt>m * n = k</tt>.
--   
--   <pre>
--   &gt;&gt;&gt; fromVector (200, 300) $ generate 60000 (\i -&gt; PixelY $ fromIntegral i / 60000)
--   &lt;Image Vector Luma: 200x300&gt;
--   </pre>
--   
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 where {
    data family MImage s arr cs e;
}

-- | Get a pixel at <tt>(i, j)</tt> location without any bounds checks.
unsafeIndex :: 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 ()

-- | Run a stateful monadic computation that generates an image.
createImage :: MArray arr cs e => (forall s. ST s (MImage s arr cs e)) -> Image arr cs e

-- | 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

-- | Get a pixel at <tt>i</tt>-th and <tt>j</tt>-th location.
--   
--   <pre>
--   &gt;&gt;&gt; let grad_gray = makeImage (200, 200) (\(i, j) -&gt; PixelY $ fromIntegral (i*j)) / (200*200)
--   
--   &gt;&gt;&gt; index grad_gray (20, 30) == PixelY ((20*30) / (200*200))
--   True
--   </pre>
index :: MArray arr cs e => Image arr cs e -> (Int, Int) -> 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

-- | Image indexing function that returns <tt><a>Nothing</a></tt> if index
--   is out of bounds, <tt><a>Just</a> px</tt> 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.
--   
--   <pre>
--              outside |  Image  | outside
--   (<a>Fill</a> 0) : 0 0 0 0 | 1 2 3 4 | 0 0 0 0
--   </pre>
Fill :: !px -> Border px

-- | Wrap around from the opposite border of the image.
--   
--   <pre>
--              outside |  Image  | outside
--   <a>Wrap</a> :     1 2 3 4 | 1 2 3 4 | 1 2 3 4
--   </pre>
Wrap :: Border px

-- | Replicate the pixel at the edge.
--   
--   <pre>
--              outside |  Image  | outside
--   <a>Edge</a> :     1 1 1 1 | 1 2 3 4 | 4 4 4 4
--   </pre>
Edge :: Border px

-- | Mirror like reflection.
--   
--   <pre>
--              outside |  Image  | outside
--   <a>Reflect</a> :  4 3 2 1 | 1 2 3 4 | 4 3 2 1
--   </pre>
Reflect :: Border px

-- | Also mirror like reflection, but without repeating the edge pixel.
--   
--   <pre>
--              outside |  Image  | outside
--   <a>Continue</a> : 1 4 3 2 | 1 2 3 4 | 3 2 1 4
--   </pre>
Continue :: Border px

-- | Border handling function. If <tt>(i, j)</tt> 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.
--   
--   <b>Note</b>: There is an implicit assumption that <tt>j &lt; n</tt>
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 (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.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 <a>Vector</a> representation.
data VU
VU :: VU

-- | Storable <a>Vector</a> 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.
--   
--   <b>Note</b>: There is an implicit assumption that <tt>j &lt; n</tt>
fromIx :: Int -> (Int, Int) -> Int


module Graphics.Image.Processing.Complex

-- | Construct a complex image from two images representing real and
--   imaginary parts.
--   
--   <pre>
--   &gt;&gt;&gt; frog &lt;- readImageRGB VU "images/frog.jpg"
--   
--   &gt;&gt;&gt; frog !+! 0
--   &lt;Image VectorUnboxed RGB (Complex Double): 200x320&gt;
--   
--   &gt;&gt;&gt; frog !+! frog
--   &lt;Image VectorUnboxed RGB (Complex Double): 200x320&gt;
--   </pre>
(!+!) :: (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)

-- | <tt><a>cisI</a> t</tt> is a complex image with magnitude 1 and phase t
--   (modulo <tt>2*<a>pi</a></tt>).
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 <tt><tt>polar'</tt></tt> 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 <tt>(-<a>pi</a>,
--   <a>pi</a>]</tt>; 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 <tt>(-<a>pi</a>,
--   <a>pi</a>]</tt>. 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)

-- | 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 <a>RGB</a> pixel.
toPixelRGB :: ToRGB cs e => Pixel cs e -> Pixel RGB Double

-- | Convert to an <a>RGB</a> image.
toImageRGB :: (ToRGB cs e, Array arr cs e, Array arr RGB Double) => Image arr cs e -> Image arr RGB Double

-- | Convert to an <a>RGBA</a> pixel.
toPixelRGBA :: ToRGBA cs e => Pixel cs e -> Pixel RGBA Double

-- | Convert to an <a>RGBA</a> image.
toImageRGBA :: (ToRGBA cs e, Array arr cs e, Array arr RGBA Double) => Image arr cs e -> Image arr RGBA Double

-- | Convert to an <a>HSI</a> pixel.
toPixelHSI :: ToHSI cs e => Pixel cs e -> Pixel HSI Double

-- | Convert to an <a>HSI</a> image.
toImageHSI :: (ToHSI cs e, Array arr cs e, Array arr HSI Double) => Image arr cs e -> Image arr HSI Double

-- | Convert to an <a>HSIA</a> pixel.
toPixelHSIA :: ToHSIA cs e => Pixel cs e -> Pixel HSIA Double

-- | Convert to an <a>HSIA</a> image.
toImageHSIA :: (ToHSIA cs e, Array arr cs e, Array arr HSIA Double) => Image arr cs e -> Image arr HSIA Double

-- | Convert to a <a>CMYK</a> pixel.
toPixelCMYK :: ToCMYK cs e => Pixel cs e -> Pixel CMYK Double

-- | Convert to a <a>CMYK</a> image.
toImageCMYK :: (ToCMYK cs e, Array arr cs e, Array arr CMYK Double) => Image arr cs e -> Image arr CMYK Double

-- | Convert to a <a>CMYKA</a> pixel.
toPixelCMYKA :: ToCMYKA cs e => Pixel cs e -> Pixel CMYKA Double

-- | Convert to a <a>CMYKA</a> image.
toImageCMYKA :: (ToCMYKA cs e, Array arr cs e, Array arr CMYKA Double) => Image arr cs e -> Image arr CMYKA Double

-- | Convert to an <a>YCbCr</a> pixel.
toPixelYCbCr :: ToYCbCr cs e => Pixel cs e -> Pixel YCbCr Double

-- | Convert to an <a>YCbCr</a> image.
toImageYCbCr :: (ToYCbCr cs e, Array arr cs e, Array arr YCbCr Double) => Image arr cs e -> Image arr YCbCr Double

-- | Convert to an <a>YCbCrA</a> pixel.
toPixelYCbCrA :: ToYCbCrA cs e => Pixel cs e -> Pixel YCbCrA Double

-- | Convert to an <a>YCbCrA</a> image.
toImageYCbCrA :: (ToYCbCrA cs e, Array arr cs e, Array arr YCbCrA Double) => Image arr cs e -> Image arr YCbCrA Double

-- | Convert to a <tt>Binary</tt> pixel.
toPixelBinary :: ColorSpace cs e => Pixel cs e -> Pixel X Bit

-- | Convert a Binary pixel to Luma pixel
fromPixelBinary :: Pixel X Bit -> Pixel Y Word8

-- | Convert to a <tt>Binary</tt> image.
toImageBinary :: (Array arr cs e, Array arr X Bit) => Image arr cs e -> Image arr X Bit

-- | Convert a Binary image to Luma image
fromImageBinary :: (Array arr X Bit, Array arr Y Word8) => Image arr X Bit -> Image arr Y Word8

-- | Under the hood, binary pixels are represented as <a>Word8</a>, but can
--   only take values of <tt>0</tt> or <tt>1</tt>. Use
--   <a>zero</a>/<a>one</a> to construct a bit and <a>on</a>/<a>off</a> to
--   construct a binary pixel.
newtype Bit
Bit :: Word8 -> Bit

-- | Represents value <a>True</a> or <tt>1</tt> in binary. Often also
--   called a foreground pixel of an object.
on :: Pixel X Bit

-- | Represents value <a>False</a> or <tt>0</tt> in binary. Often also
--   called a background pixel.
off :: Pixel X Bit

-- | Test if Pixel's value is <a>on</a>.
isOn :: Pixel X Bit -> Bool

-- | Test if Pixel's value is <a>off</a>.
isOff :: Pixel X Bit -> Bool

-- | Convert a <a>Bool</a> to a binary pixel.
--   
--   <pre>
--   &gt;&gt;&gt; isOn (fromBool True)
--   True
--   </pre>
fromBool :: Bool -> Pixel X Bit
zero :: Bit
one :: Bit
bit2bool :: Bit -> Bool
bool2bit :: Bool -> Bit
toNum :: Num a => Bit -> a
fromNum :: (Eq a, Num a) => a -> Bit

-- | Complex numbers are an algebraic type.
--   
--   For a complex number <tt>z</tt>, <tt><a>abs</a> z</tt> is a number
--   with the magnitude of <tt>z</tt>, but oriented in the positive real
--   direction, whereas <tt><a>signum</a> z</tt> has the phase of
--   <tt>z</tt>, but unit magnitude.
--   
--   The <a>Foldable</a> and <a>Traversable</a> 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.
--   
--   <pre>
--   PixelRGB 4 8 6 <a>+:</a> PixelRGB 7 1 1 <b>==</b> PixelRGB (4 <a>:+</a> 7) (8 <a>:+</a> 1) (6 <a>:+</a> 1)
--   </pre>
(+:) :: 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)

-- | <tt><a>cis</a> t</tt> is a complex pixel with magnitude 1 and phase t
--   (modulo <tt>2*<a>pi</a></tt>).
cis :: (Applicative (Pixel cs), RealFloat e) => Pixel cs e -> Pixel cs (Complex e)

-- | The function <tt><a>polar</a></tt> 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 <tt>(-<a>pi</a>,
--   <a>pi</a>]</tt>; 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 <tt>(-<a>pi</a>,
--   <a>pi</a>]</tt>. 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)

-- | Apply a left fold to each of the pixels in the image.
squashWith :: (Array arr cs e, Array arr X b) => (b -> e -> b) -> b -> Image arr cs e -> Image arr X b

-- | Combination of zipWith and simultanious left fold on two pixels at the
--   same time.
squashWith2 :: (Array arr cs e, Array arr X b) => (b -> e -> e -> b) -> b -> Image arr cs e -> Image arr cs e -> Image arr X b

-- | Separate a Pixel into a list of components with <a>X</a> pixels
--   containing every component from the pixel.
--   
--   <pre>
--   &gt;&gt;&gt; toPixelsX (PixelRGB 4 5 6)
--   [&lt;X:(4)&gt;,&lt;X:(5)&gt;,&lt;X:(6)&gt;]
--   </pre>
toPixelsX :: ColorSpace cs e => Pixel cs e -> [Pixel X e]

-- | Combine a list of <a>X</a> pixels into a Pixel with a specified
--   channel order. Not the most efficient way to construct a pixel, but
--   might prove useful to someone.
--   
--   <pre>
--   &gt;&gt;&gt; fromPixelsX [(RedRGB, 3), (BlueRGB, 5), (GreenRGB, 4)]
--   &lt;RGB:(3.0|4.0|5.0)&gt;
--   
--   &gt;&gt;&gt; fromPixelsX $ zip (enumFrom RedRGB) (toPixelsX $ PixelRGB 4 5 6)
--   &lt;RGB:(4.0|5.0|6.0)&gt;
--   </pre>
fromPixelsX :: ColorSpace cs e => [(cs, Pixel X e)] -> Pixel cs e

-- | Separate an image into a list of images with <a>X</a> pixels
--   containing every channel from the source image.
--   
--   <pre>
--   &gt;&gt;&gt; frog &lt;- readImageRGB "images/frog.jpg"
--   
--   &gt;&gt;&gt; let [frog_red, frog_green, frog_blue] = toImagesX frog
--   
--   &gt;&gt;&gt; writeImage "images/frog_red.png" $ toImageY frog_red
--   
--   &gt;&gt;&gt; writeImage "images/frog_green.jpg" $ toImageY frog_green
--   
--   &gt;&gt;&gt; writeImage "images/frog_blue.jpg" $ toImageY frog_blue
--   </pre>
--   
toImagesX :: (Array arr cs e, Array arr X e) => Image arr cs e -> [Image arr X e]

-- | Combine a list of images with <a>X</a> pixels into an image of any
--   color space, by supplying an order of color space channels.
--   
--   For example here is a frog with swapped <tt>BlueRGB</tt> and
--   <tt>GreenRGB</tt> channels.
--   
--   <pre>
--   &gt;&gt;&gt; writeImage "images/frog_rbg.jpg" $ fromImagesX [(RedRGB, frog_red), (BlueRGB, frog_green), (GreenRGB, frog_blue)]
--   </pre>
--   
--   
--   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:
--   
--   <pre>
--   <a>map</a> (\(PixelRGB r g b) -&gt; PixelRGB r b g) frog
--   </pre>
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 <a>Float</a> or <a>Double</a> precision.
eqTolPx :: (ColorSpace cs e, Ord e) => e -> Pixel cs e -> Pixel cs e -> Bool

-- | Luma or brightness, which is usually denoted as <tt>Y'</tt>.
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 <a>RGB</a> color space.
class ColorSpace cs e => ToRGB cs e

-- | Convert to an <a>RGB</a> pixel.
toPixelRGB :: ToRGB cs e => Pixel cs e -> Pixel RGB Double

-- | Conversion to <a>RGBA</a> from another color space with Alpha channel.
class ToRGB cs e => ToRGBA cs e where toPixelRGBA = addAlpha 1 . toPixelRGB

-- | Convert to an <a>RGBA</a> 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 <a>HSI</a> color space.
class ColorSpace cs e => ToHSI cs e

-- | Convert to an <a>HSI</a> pixel.
toPixelHSI :: ToHSI cs e => Pixel cs e -> Pixel HSI Double

-- | Conversion to <a>HSIA</a> from another color space with Alpha channel.
class ToHSI cs e => ToHSIA cs e where toPixelHSIA = addAlpha 1 . toPixelHSI

-- | Convert to an <a>HSIA</a> 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 <a>CMYK</a> color space.
class ColorSpace cs e => ToCMYK cs e

-- | Convert to a <a>CMYK</a> pixel.
toPixelCMYK :: ToCMYK cs e => Pixel cs e -> Pixel CMYK Double

-- | Conversion to <a>CMYKA</a>.
class ToCMYK cs e => ToCMYKA cs e where toPixelCMYKA = addAlpha 1 . toPixelCMYK

-- | Convert to a <a>CMYKA</a> 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 <b>Y'</b>)
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 <b>Y'</b>)
LumaYCbCrA :: YCbCrA

-- | Blue difference chroma component
CBlueYCbCrA :: YCbCrA

-- | Red difference chroma component
CRedYCbCrA :: YCbCrA

-- | Alpha component.
AlphaYCbCrA :: YCbCrA

-- | Conversion to <a>YCbCr</a> color space.
class ColorSpace cs e => ToYCbCr cs e

-- | Convert to an <a>YCbCr</a> pixel.
toPixelYCbCr :: ToYCbCr cs e => Pixel cs e -> Pixel YCbCr Double

-- | Conversion to <a>YCbCrA</a> from another color space with Alpha
--   channel.
class ToYCbCr cs e => ToYCbCrA cs e where toPixelYCbCrA = addAlpha 1 . toPixelYCbCr

-- | Convert to an <a>YCbCrA</a> pixel.
toPixelYCbCrA :: ToYCbCrA cs e => Pixel cs e -> Pixel YCbCrA Double

-- | 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 <a>Y</a> should be used instead.
data X
X :: X

-- | Change image precision to <a>Word8</a>.
toWord8I :: (Functor (Pixel cs), Array arr cs e, Array arr cs Word8) => Image arr cs e -> Image arr cs Word8

-- | Change image precision to <a>Word16</a>.
toWord16I :: (Functor (Pixel cs), Array arr cs e, Array arr cs Word16) => Image arr cs e -> Image arr cs Word16

-- | Change image precision to <a>Word32</a>.
toWord32I :: (Functor (Pixel cs), Array arr cs e, Array arr cs Word32) => Image arr cs e -> Image arr cs Word32

-- | Change image precision to <a>Float</a>.
toFloatI :: (Functor (Pixel cs), Array arr cs e, Array arr cs Float) => Image arr cs e -> Image arr cs Float

-- | Change image precision to <a>Double</a>.
toDoubleI :: (Functor (Pixel cs), Array arr cs e, Array arr cs Double) => Image arr cs e -> Image arr cs Double

-- | Change pixel precision to <a>Word8</a>.
toWord8Px :: (Functor (Pixel cs), Elevator e) => Pixel cs e -> Pixel cs Word8

-- | 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.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.ToYA Graphics.Image.ColorSpace.X.X Graphics.Image.ColorSpace.Binary.Bit
instance Graphics.Image.ColorSpace.ToY Graphics.Image.ColorSpace.Y.Y e => Graphics.Image.ColorSpace.ToYA Graphics.Image.ColorSpace.Y.Y e
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.X.X 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.X.X 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.IO.Formats

-- | Bitmap image with <tt>.bmp</tt> extension.
data BMP
BMP :: BMP

-- | Graphics Interchange Format image with <tt>.gif</tt> extension.
data GIF
GIF :: GIF

-- | Graphics Interchange Format animated image with <tt>.gif</tt>
--   extension.

-- | <i>Deprecated: use (<a>Seq</a> <a>GIF</a>) instead</i>
data GIFA

-- | <i>Deprecated: use (<a>Seq</a> <a>GIF</a>) instead</i>
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 <tt>.hdr</tt> or <tt>.pic</tt>
--   extension.
data HDR
HDR :: HDR

-- | Joint Photographic Experts Group image with <tt>.jpg</tt> or
--   <tt>.jpeg</tt> extension.
data JPG
JPG :: JPG

-- | Portable Network Graphics image with <tt>.png</tt> extension.
data PNG
PNG :: PNG

-- | Truevision Graphics Adapter image with .tga extension.
data TGA
TGA :: TGA

-- | Tagged Image File Format image with <tt>.tif</tt> or <tt>.tiff</tt>
--   extension.
data TIF
TIF :: TIF
toJPImageY8 :: Image VS Y Word8 -> Image Pixel8
toJPImageYA8 :: Image VS YA Word8 -> Image PixelYA8
toJPImageY16 :: Image VS Y Word16 -> Image Pixel16
toJPImageYA16 :: Image VS YA Word16 -> Image PixelYA16
toJPImageYF :: Image VS Y Float -> Image PixelF
toJPImageRGB8 :: Image VS RGB Word8 -> Image PixelRGB8
toJPImageRGBA8 :: Image VS RGBA Word8 -> Image PixelRGBA8
toJPImageRGB16 :: Image VS RGB Word16 -> Image PixelRGB16
toJPImageRGBA16 :: Image VS RGBA Word16 -> Image PixelRGBA16
toJPImageRGBF :: Image VS RGB Float -> Image PixelRGBF
toJPImageYCbCr8 :: Image VS YCbCr Word8 -> Image PixelYCbCr8
toJPImageCMYK8 :: Image VS CMYK Word8 -> Image PixelCMYK8
toJPImageCMYK16 :: Image VS CMYK Word16 -> Image PixelCMYK16
fromJPImageY8 :: Image Pixel8 -> Image VS Y Word8
fromJPImageYA8 :: Image PixelYA8 -> Image VS YA Word8
fromJPImageY16 :: Image Pixel16 -> Image VS Y Word16
fromJPImageYA16 :: Image PixelYA16 -> Image VS YA Word16
fromJPImageYF :: Image PixelF -> Image VS Y Float
fromJPImageRGB8 :: Image PixelRGB8 -> Image VS RGB Word8
fromJPImageRGBA8 :: Image PixelRGBA8 -> Image VS RGBA Word8
fromJPImageRGB16 :: Image PixelRGB16 -> Image VS RGB Word16
fromJPImageRGBA16 :: Image PixelRGBA16 -> Image VS RGBA Word16
fromJPImageRGBF :: Image PixelRGBF -> Image VS RGB Float
fromJPImageYCbCr8 :: Image PixelYCbCr8 -> Image VS YCbCr Word8
fromJPImageCMYK8 :: Image PixelCMYK8 -> Image VS CMYK Word8
fromJPImageCMYK16 :: Image PixelCMYK16 -> Image VS CMYK Word16

-- | Netpbm: portable bitmap image with <tt>.pbm</tt> extension.
data PBM
PBM :: PBM

-- | Netpbm: portable graymap image with <tt>.pgm</tt> extension.
data PGM
PGM :: PGM

-- | Netpbm: portable pixmap image with <tt>.ppm</tt> extension.
data PPM
PPM :: PPM

-- | 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 file extensions for this image format, if more than one is
--   commonly used, eg. ".jpeg", ".jpg".
exts :: ImageFormat format => format -> [String]

-- | Checks if a file extension corresponds to the format, eg. <tt>isFormat
--   ".png" PNG == True</tt>
isFormat :: ImageFormat format => String -> format -> Bool

-- | 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 <a>Double</a> 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 <a>ByteString</a>.
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 into <a>ByteString</a>.
encode :: Writable img format => format -> [SaveOption format] -> img -> ByteString

-- | Used during converting pixels between libraries.
class Convertible cs e
convert :: (Convertible cs e, ToYA cs' e', ToRGBA cs' e', Array arr cs' e', Array arr cs e) => Image arr cs' e' -> Image arr cs e

-- | Special wrapper for formats that support encoding/decoding sequence of
--   images.
newtype Seq f
Seq :: f -> Seq f

-- | Constraint type synonym for all readable formats.
type AllReadable arr cs = (Readable (Image arr cs Double) BMP, Readable (Image arr cs Double) GIF, Readable (Image arr cs Double) HDR, Readable (Image arr cs Double) JPG, Readable (Image arr cs Double) PNG, Readable (Image arr cs Double) TGA, Readable (Image arr cs Double) TIF, Readable (Image arr cs Double) PPM)

-- | Constraint type synonym for all writable formats.
type AllWritable arr cs = (Writable (Image arr cs Double) BMP, Writable (Image arr cs Double) GIF, Writable (Image arr cs Double) HDR, Writable (Image arr cs Double) JPG, Writable (Image arr cs Double) PNG, Writable (Image arr cs Double) TGA, Writable (Image arr cs Double) TIF)

-- | Constraint type synonym for encoding a Complex image.
type ComplexWritable format arr cs e = (Array arr cs e, Array arr cs (Complex e), RealFloat e, Applicative (Pixel cs), Writable (Image arr cs e) format)
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.Formats.AllReadable arr cs => 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.Formats.AllWritable arr cs => Graphics.Image.IO.Base.Writable (Graphics.Image.Interface.Image arr cs GHC.Types.Double) Graphics.Image.IO.Formats.OutputFormat


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, <a>Left</a>
--   containing all errors for each attempted format will be returned, and
--   <a>Right</a> containing an image otherwise. Image will be read with a
--   type signature specified:
--   
--   <pre>
--   &gt;&gt;&gt; frog &lt;- readImage "images/frog.jpg" :: IO (Either String (Image VS RGB Word8))
--   
--   &gt;&gt;&gt; displayImage frog
--   </pre>
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 <a>readImage</a>, 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 <a>VS</a> image representation can be
--   read natively, but <a>exchange</a> can be use later to switch to a
--   different representation. For instance, "frog.jpg" image can be read
--   into it's <a>YCbCr</a> colorspace with <a>Word8</a> precision:
--   
--   <pre>
--   &gt;&gt;&gt; readImageExact JPG "images/frog.jpg" :: IO (Either String (Image VS YCbCr Word8))
--   Right &lt;Image VS YCbCr (Word8): 200x320&gt;
--   </pre>
--   
--   The drawback here is that colorspace and precision has to match
--   exactly, otherwise it will return an error:
--   
--   <pre>
--   &gt;&gt;&gt; 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."
--   </pre>
--   
--   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
--   <a>Readable</a> class for all images that can be decoded.
readImageExact :: Readable img format => format -> FilePath -> IO (Either String img)

-- | Just like <a>readImageExact</a>, but will throw an exception if
--   incorrect format is detected.
readImageExact' :: Readable b format => format -> FilePath -> IO b

-- | Just like <a>readImage</a>, this function will guess an output file
--   format from the extension and write to file any image that is in one
--   of <a>Y</a>, <a>YA</a>, <a>RGB</a> or <a>RGBA</a> color spaces with
--   <a>Double</a> 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 <a>PNG</a> format, an (<a>Image</a>
--   <tt>arr</tt> <a>RGBA</a> <a>Double</a>) would be written as
--   <tt>RGBA16</tt>, hence preserving transparency and using highest
--   supported precision <a>Word16</a>. At the same time, writing that
--   image in <a>GIF</a> format would save it in <tt>RGB8</tt>, since
--   <a>Word8</a> is the highest precision <a>GIF</a> 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:
--   
--   <ul>
--   <li><tt>FilePath</tt> - to the actual viewer executable.</li>
--   <li><tt>[String]</tt> - command line arguments that will be passed to
--   the executable.</li>
--   <li><tt>Int</tt> - position index in the above list where
--   <a>FilePath</a> to an image should be injected</li>
--   </ul>
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 <tt>.tiff</tt> 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

-- | <pre>
--   eog /tmp/hip/img.tiff
--   </pre>
--   
--   <a>Eye of GNOME</a>
eogViewer :: ExternalViewer

-- | <pre>
--   gpicview /tmp/hip/img.tiff
--   </pre>
--   
--   <a>GPicView</a>
gpicviewViewer :: ExternalViewer

-- | <pre>
--   feh --fullscreen --auto-zoom /tmp/hip/img.tiff
--   </pre>
--   
--   <a>FEH</a>
fehViewer :: ExternalViewer

-- | <pre>
--   gimp /tmp/hip/img.tiff
--   </pre>
--   
--   <a>GIMP</a>
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

-- | Converts an image to Luma and performs histogram equalization.
equalizeHistogram :: (ToY cs e, Array arr cs e, Array arr Y Double, Array arr X Word8, MArray arr X Word8) => Image arr cs e -> Image arr Y Double

-- | Discrete cumulative distribution function.
cdf :: MArray arr X e => Image arr X e -> Vector Double

-- | Display image histograms using an external program. Works in a similar
--   way as <a>displayImage</a>.
--   
--   <pre>
--   &gt;&gt;&gt; frog &lt;- readImageRGB VU "images/frog.jpg"
--   
--   &gt;&gt;&gt; displayHistograms $ getHistograms frog
--   </pre>
displayHistograms :: Histograms -> IO ()

-- | Write histograms into a PNG image file.
--   
--   <pre>
--   &gt;&gt;&gt; frog &lt;- readImageRGB VU "images/frog.jpg"
--   
--   &gt;&gt;&gt; writeHistograms "images/frog_histogram.svg" $ getHistograms frog
--   </pre>
--   
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 X Bit) => (Pixel cs e -> Bool) -> Image arr cs e -> Image arr X Bit

-- | Construct a binary image using a predicate from two source images.
toImageBinaryUsing2 :: (Array arr cs e, Array arr X Bit) => (Pixel cs e -> Pixel cs e -> Bool) -> Image arr cs e -> Image arr cs e -> Image arr X Bit
threshold :: (Applicative (Pixel cs), Array arr cs e, Array arr cs Bit) => Pixel cs (e -> Bool) -> Image arr cs e -> Image arr cs Bit
threshold2 :: (Applicative (Pixel cs), Array arr cs e', Array arr cs e, Array arr cs Bit) => Pixel cs (e' -> e -> Bool) -> Image arr cs e' -> Image arr cs e -> Image arr cs Bit

-- | Threshold a source image with an applicative pixel.
--   
--   <pre>
--   &gt;&gt;&gt; yield &lt;- readImageRGB VU "images/yield.jpg"
--   
--   &gt;&gt;&gt; writeImageExact PNG [] "images/yield_bin.png" $ thresholdWith (PixelRGB (&gt;0.55) (&lt;0.6) (&lt;0.5)) yield
--   </pre>
--   
thresholdWith :: (Applicative (Pixel cs), Foldable (Pixel cs), Array arr cs e, Array arr X Bit) => Pixel cs (e -> Bool) -> Image arr cs e -> Image arr X Bit

-- | Compare two images with an applicative pixel. Works just like
--   <a>thresholdWith</a>, but on two images.
thresholdWith2 :: (Applicative (Pixel cs), Foldable (Pixel cs), Array arr cs e1, Array arr cs e2, Array arr X Bit) => Pixel cs (e1 -> e2 -> Bool) -> Image arr cs e1 -> Image arr cs e2 -> Image arr X Bit

-- | Compare two images with an applicative pixel. Works just like
--   <a>thresholdWith</a>, but on two images.

-- | <i>Deprecated: Use <a>thresholdWith2</a> instead.</i>
compareWith :: (Applicative (Pixel cs), Foldable (Pixel cs), Array arr cs e1, Array arr cs e2, Array arr X Bit) => Pixel cs (e1 -> e2 -> Bool) -> Image arr cs e1 -> Image arr cs e2 -> Image arr X Bit

-- | <a>Thresholding</a> 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:
--   
--   <pre>
--   &gt;&gt;&gt; frog &lt;- readImageY VU "images/frog.jpg"
--   
--   &gt;&gt;&gt; frog .==. PixelY 0    -- (or: PixelY 0 .==. frog)
--   
--   &gt;&gt;&gt; frog .&lt;. flipH frog   -- (or: flipH frog .&gt;. frog)
--   </pre>
class Thresholding a b arr | a b -> arr
(!==!) :: (Thresholding a b arr, Applicative (Pixel cs), Array arr cs e, Array arr cs Bit) => a cs e -> b cs e -> Image arr cs Bit
(!/=!) :: (Thresholding a b arr, Applicative (Pixel cs), Array arr cs e, Array arr cs Bit) => a cs e -> b cs e -> Image arr cs Bit
(!<!) :: (Thresholding a b arr, Ord e, Applicative (Pixel cs), Array arr cs e, Array arr cs Bit) => a cs e -> b cs e -> Image arr cs Bit
(!<=!) :: (Thresholding a b arr, Ord e, Applicative (Pixel cs), Array arr cs e, Array arr cs Bit) => a cs e -> b cs e -> Image arr cs Bit
(!>!) :: (Thresholding a b arr, Ord e, Applicative (Pixel cs), Array arr cs e, Array arr cs Bit) => a cs e -> b cs e -> Image arr cs Bit
(!>=!) :: (Thresholding a b arr, Ord e, Applicative (Pixel cs), Array arr cs e, Array arr cs Bit) => a cs e -> b cs e -> Image arr cs Bit
(.==.) :: (Thresholding a b arr, Array arr cs e, Array arr X Bit) => a cs e -> b cs e -> Image arr X Bit
(./=.) :: (Thresholding a b arr, Array arr cs e, Array arr X Bit) => a cs e -> b cs e -> Image arr X Bit
(.<.) :: (Thresholding a b arr, Ord (Pixel cs e), Array arr cs e, Array arr X Bit) => a cs e -> b cs e -> Image arr X Bit
(.<=.) :: (Thresholding a b arr, Ord (Pixel cs e), Array arr cs e, Array arr X Bit) => a cs e -> b cs e -> Image arr X Bit
(.>.) :: (Thresholding a b arr, Ord (Pixel cs e), Array arr cs e, Array arr X Bit) => a cs e -> b cs e -> Image arr X Bit
(.>=.) :: (Thresholding a b arr, Ord (Pixel cs e), Array arr cs e, Array arr X Bit) => a cs e -> b cs e -> Image arr X Bit

-- | Disjunction of all pixels in a Binary image
or :: Array arr X Bit => Image arr X Bit -> Bool

-- | Conjunction of all pixels in a Binary image
and :: Array arr X Bit => Image arr X Bit -> Bool

-- | Pixel wise <tt>AND</tt> operator on binary images.
(!&&!) :: Array arr cs Bit => Image arr cs Bit -> Image arr cs Bit -> Image arr cs Bit
infixr 3 !&&!

-- | Pixel wise <tt>OR</tt> operator on binary images.
(!||!) :: Array arr cs Bit => Image arr cs Bit -> Image arr cs Bit -> Image arr cs Bit
infixr 2 !||!

-- | Pixel wise <tt>AND</tt> operator on binary images. Unlike
--   <a>!&amp;&amp;!</a> this operator will also <tt>AND</tt> pixel
--   componenets.
(.&&.) :: (Array arr cs Bit, Array arr X Bit) => Image arr cs Bit -> Image arr cs Bit -> Image arr X Bit
infixr 3 .&&.

-- | Pixel wise <tt>OR</tt> operator on binary images. Unlike <a>!||!</a>
--   this operator will also <tt>OR</tt> pixel componenets.
(.||.) :: (Array arr cs Bit, Array arr X Bit) => Image arr cs Bit -> Image arr cs Bit -> Image arr X Bit
infixr 2 .||.

-- | Complement each pixel in a binary image
invert :: Array arr cs Bit => Image arr cs Bit -> Image arr cs Bit

-- | Join each component of a pixel with a binary <tt><a>.|.</a></tt>
--   operator.
disjunction :: (Array arr cs Bit, Array arr X Bit) => Image arr cs Bit -> Image arr X Bit

-- | Join each component of a pixel with a binary <tt><a>.&amp;.</a></tt>
--   operator.
conjunction :: (Array arr cs Bit, Array arr X Bit) => Image arr cs Bit -> Image arr X Bit

-- | Erosion is defined as: <b>{E = B ⊖ S = {m,n|Sₘₙ⊆B}</b>
--   
--   <pre>
--   &gt;&gt;&gt; writeImageExact PNG [] "images/figure_erode.png" $ pixelGrid 10 $ fromImageBinary $ erode struct figure
--   </pre>
--   
--   eroded with is
erode :: Array arr X Bit => Image arr X Bit -> Image arr X Bit -> Image arr X Bit

-- | Dialation is defined as: <b>{D = B ⊕ S = {m,n|Sₘₙ∩B≠∅}</b>
--   
--   <pre>
--   &gt;&gt;&gt; writeImageExact PNG [] "images/figure_dialate.png" $ pixelGrid 10 $ fromImageBinary $ dialate struct figure
--   </pre>
--   
--   dialated with is
dialate :: Array arr X Bit => Image arr X Bit -> Image arr X Bit -> Image arr X Bit

-- | Opening is defined as: <b>{B ○ S = (B ⊖ S) ⊕ S}</b>
--   
--   <pre>
--   &gt;&gt;&gt; writeImageExact PNG [] "images/figure_open.png" $ pixelGrid 10 $ fromImageBinary $ open struct figure
--   </pre>
--   
--   opened with is
open :: Array arr X Bit => Image arr X Bit -> Image arr X Bit -> Image arr X Bit

-- | Closing is defined as: <b>{B ● S = (B ⊕ S) ⊖ S}</b>
--   
--   <pre>
--   &gt;&gt;&gt; writeImageExact PNG [] "images/figure_close.png" $ pixelGrid 10 $ fromImageBinary $ close struct figure
--   </pre>
--   
--   closed with is
close :: Array arr X Bit => Image arr X Bit -> Image arr X Bit -> Image arr X Bit
instance 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.X.X 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.X.X Graphics.Image.ColorSpace.Binary.Bit => Graphics.Image.Processing.Binary.Thresholding (Graphics.Image.Interface.Image arr) Graphics.Image.Interface.Pixel arr


module Graphics.Image.Processing.Filter

-- | Filter that can be applied to an image using <a>applyFilter</a>.
data Filter arr cs e

-- | Apply a filter to an image
applyFilter :: Filter arr cs e -> Image arr cs e -> Image arr cs e

-- | Used to specify direction for some filters.
data Direction
Vertical :: Direction
Horizontal :: Direction

-- | Create a Gaussian Filter.
gaussianLowPass :: (Array arr cs e, Array arr X e, Floating e, Fractional e) => Int -> e -> Border (Pixel cs e) -> Filter arr cs e

-- | Create a Gaussian Blur filter. Radius will be derived from standard
--   deviation: <tt>ceiling (2*sigma)</tt> and <a>Edge</a> border
--   resolution will be utilized. If custom radius and/or border resolution
--   is desired, <a>gaussianLowPass</a> can be used instead.
gaussianBlur :: (Array arr cs e, Array arr X e, Floating e, RealFrac e) => e -> Filter arr cs e
sobelFilter :: (Array arr cs e, Array arr X e) => Direction -> Border (Pixel cs e) -> Filter arr cs e
sobelOperator :: (Array arr cs e, Array arr X e, Floating e) => Image arr cs e -> Image arr cs e
prewittFilter :: (Array arr cs e, Array arr X e) => Direction -> Border (Pixel cs e) -> Filter arr cs e
prewittOperator :: (Array arr cs e, Array arr X e, Floating e) => Image arr cs e -> Image arr cs 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:
--   
--   <pre>
--   &gt;&gt;&gt; frog &lt;- readImageRGB RPU "images/frog.jpg"
--   
--   &gt;&gt;&gt; displayImage $ downsample ((0 ==) . (`mod` 5)) odd frog
--   </pre>
--   
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 <tt>(before, after)</tt> 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:
--   
--   <pre>
--   &gt;&gt;&gt; frog &lt;- readImageRGB RPU "images/frog.jpg"
--   
--   &gt;&gt;&gt; displayImage $ upsample (const (0, 0)) (\ k -&gt; if k `mod` 10 == 0 then (2, 4) else (0, 0)) frog
--   </pre>
--   
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 <tt>(delatM,
--   deltaN)</tt> rows and columns, while specifying a border resolution
--   strategy.
--   
--   <pre>
--   &gt;&gt;&gt; frog &lt;- readImageRGB VU "images/frog.jpg"
--   
--   &gt;&gt;&gt; writeImage "images/frog_translate_wrap.jpg" $ translate Wrap (50, 100) frog
--   
--   &gt;&gt;&gt; writeImage "images/frog_translate_edge.jpg" $ translate Edge (50, 100) frog
--   </pre>
--   
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:
--   
--   <pre>
--   &gt;&gt;&gt; logo &lt;- readImageRGBA VU "images/logo_40.png"
--   
--   &gt;&gt;&gt; let incBy (fm, fn) = (rows logo * fm, cols logo * fn)
--   
--   &gt;&gt;&gt; writeImage "images/logo_tile.png" $ canvasSize Wrap (incBy (6, 10)) logo
--   
--   &gt;&gt;&gt; writeImage "images/logo_center.png" $ translate (Fill 0) (incBy (2, 3)) $ canvasSize (Fill 0) (incBy (5, 7)) logo
--   </pre>
--   
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 <tt>m</tt> rows
--   and <tt>n</tt> columns. Make sure <tt>(i + m, j + n)</tt> 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.
--   
--   <pre>
--   &gt;&gt;&gt; frog &lt;- readImageRGB VU "images/frog.jpg"
--   
--   &gt;&gt;&gt; writeImage "images/frog_flipV.jpg" $ flipV frog
--   </pre>
--   
flipV :: Array arr cs e => Image arr cs e -> Image arr cs e

-- | Flip an image horizontally.
--   
--   <pre>
--   &gt;&gt;&gt; frog &lt;- readImageRGB VU "images/frog.jpg"
--   
--   &gt;&gt;&gt; writeImage "images/frog_flipH.jpg" $ flipH frog
--   </pre>
--   
flipH :: Array arr cs e => Image arr cs e -> Image arr cs e

-- | Rotate an image clockwise by 90°.
--   
--   <pre>
--   &gt;&gt;&gt; frog &lt;- readImageRGB VU "images/frog.jpg"
--   
--   &gt;&gt;&gt; writeImage "images/frog_rotate90.jpg" $ rotate90 frog
--   </pre>
--   
rotate90 :: Array arr cs e => Image arr cs e -> Image arr cs e

-- | Rotate an image by 180°.
--   
--   <pre>
--   &gt;&gt;&gt; frog &lt;- readImageRGB VU "images/frog.jpg"
--   
--   &gt;&gt;&gt; writeImage "images/frog_rotate180.jpg" $ rotate180 frog
--   </pre>
--   
rotate180 :: Array arr cs e => Image arr cs e -> Image arr cs e

-- | Rotate an image clockwise by 270°.
--   
--   <pre>
--   &gt;&gt;&gt; frog &lt;- readImageRGB VU "images/frog.jpg"
--   
--   &gt;&gt;&gt; writeImage "images/frog_rotate270.jpg" $ rotate270 frog
--   </pre>
--   
rotate270 :: Array arr cs e => Image arr cs e -> Image arr cs e

-- | Rotate an image clockwise by an angle Θ in radians.
--   
--   <pre>
--   &gt;&gt;&gt; frog &lt;- readImageRGBA VU "images/frog.jpg"
--   
--   &gt;&gt;&gt; writeImage "images/frog_rotate330.png" $ rotate Bilinear (Fill 0) (11*pi/6) frog
--   </pre>
--   
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.
--   
--   <pre>
--   &gt;&gt;&gt; frog &lt;- readImageRGB VU "images/frog.jpg"
--   
--   &gt;&gt;&gt; writeImage "images/frog_resize.jpg" $ resize Bilinear Edge (100, 640) frog
--   </pre>
--   
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.
--   
--   <pre>
--   scale <a>Bilinear</a> <a>Edge</a> (0.5, 2) frog == resize <a>Bilinear</a> <a>Edge</a> (100, 640) frog
--   </pre>
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 <a>Sobel operator</a>:
--   
--   <pre>
--   &gt;&gt;&gt; frog &lt;- readImageY RPU "images/frog.jpg"
--   
--   &gt;&gt;&gt; let frogX = convolve Edge (fromLists [[-1, 0, 1], [-2, 0, 2], [-1, 0, 1]]) frog
--   
--   &gt;&gt;&gt; let frogY = convolve Edge (fromLists [[-1,-2,-1], [ 0, 0, 0], [ 1, 2, 1]]) frog
--   
--   &gt;&gt;&gt; displayImage $ normalize $ sqrt (frogX ^ 2 + frogY ^ 2)
--   </pre>
--   
convolve :: (Array arr X e, Array arr cs e) => Border (Pixel cs e) -> Image arr X 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 X e, Array arr cs e) => Border (Pixel cs e) -> [Pixel X 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 X e, Array arr cs e) => Border (Pixel cs e) -> [Pixel X e] -> Image arr cs e -> Image arr cs e

-- | Correlate an image with a kernel. Border resolution technique is
--   required.
correlate :: (Array arr X e, Array arr cs e) => Border (Pixel cs e) -> Image arr X 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.
--   
--   <pre>
--              outside |  Image  | outside
--   (<a>Fill</a> 0) : 0 0 0 0 | 1 2 3 4 | 0 0 0 0
--   </pre>
Fill :: !px -> Border px

-- | Wrap around from the opposite border of the image.
--   
--   <pre>
--              outside |  Image  | outside
--   <a>Wrap</a> :     1 2 3 4 | 1 2 3 4 | 1 2 3 4
--   </pre>
Wrap :: Border px

-- | Replicate the pixel at the edge.
--   
--   <pre>
--              outside |  Image  | outside
--   <a>Edge</a> :     1 1 1 1 | 1 2 3 4 | 4 4 4 4
--   </pre>
Edge :: Border px

-- | Mirror like reflection.
--   
--   <pre>
--              outside |  Image  | outside
--   <a>Reflect</a> :  4 3 2 1 | 1 2 3 4 | 4 3 2 1
--   </pre>
Reflect :: Border px

-- | Also mirror like reflection, but without repeating the edge pixel.
--   
--   <pre>
--              outside |  Image  | outside
--   <a>Continue</a> : 1 4 3 2 | 1 2 3 4 | 3 2 1 4
--   </pre>
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.
--   
--   <pre>
--   &gt;&gt;&gt; frog &lt;- readImageRGB VU "images/frog.jpg"
--   
--   &gt;&gt;&gt; writeImage "images/frog_eye_grid.png" $ pixelGrid 10 $ crop (51, 112) (20, 20) frog
--   </pre>
--   
pixelGrid :: Array arr cs e => Word8 -> Image arr cs e -> Image arr cs e


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 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.
--   
--   <pre>
--              outside |  Image  | outside
--   (<a>Fill</a> 0) : 0 0 0 0 | 1 2 3 4 | 0 0 0 0
--   </pre>
Fill :: !px -> Border px

-- | Wrap around from the opposite border of the image.
--   
--   <pre>
--              outside |  Image  | outside
--   <a>Wrap</a> :     1 2 3 4 | 1 2 3 4 | 1 2 3 4
--   </pre>
Wrap :: Border px

-- | Replicate the pixel at the edge.
--   
--   <pre>
--              outside |  Image  | outside
--   <a>Edge</a> :     1 1 1 1 | 1 2 3 4 | 4 4 4 4
--   </pre>
Edge :: Border px

-- | Mirror like reflection.
--   
--   <pre>
--              outside |  Image  | outside
--   <a>Reflect</a> :  4 3 2 1 | 1 2 3 4 | 4 3 2 1
--   </pre>
Reflect :: Border px

-- | Also mirror like reflection, but without repeating the edge pixel.
--   
--   <pre>
--              outside |  Image  | outside
--   <a>Continue</a> : 1 4 3 2 | 1 2 3 4 | 3 2 1 4
--   </pre>
Continue :: Border px

-- | Unboxed <a>Vector</a> representation.
data VU
VU :: VU

-- | Storable <a>Vector</a> 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:
--   
--   <ul>
--   <li><tt><b><a>Array</a> arr cs e</b></tt> - this is a base class for
--   every <b><tt><a>Image</a></tt> <tt>arr</tt> <tt>cs</tt>
--   <tt>e</tt></b>, where <tt><b>arr</b></tt> stands for an underlying
--   array representation, <tt><b>cs</b></tt> is the <a>ColorSpace</a> of
--   an image and <tt><b>e</b></tt> is the type denoting precision of an
--   image (<tt>Int</tt>, <tt>Word</tt>, <tt>Double</tt>, etc.) .</li>
--   <li><tt><b><a>MArray</a> arr cs e</b></tt> - is a kind of array, that
--   can be indexed in constant time and allows monadic operations and
--   mutation on <b><tt><a>MImage</a></tt> <tt>st</tt> <tt>arr</tt>
--   <tt>cs</tt> <tt>e</tt></b>, which is <a>Image</a>'s mutable
--   cousin.</li>
--   </ul>
--   
--   Representations using <a>Vector</a> and <a>Repa</a> packages:
--   
--   <ul>
--   <li><a>VU</a> - Vector Unboxed representation.</li>
--   <li><a>VS</a> - Vector Storable representation.</li>
--   <li><a>RSU</a> - Repa Sequential Unboxed array representation
--   (computation is done sequentially).</li>
--   <li><a>RPU</a> - Repa Parallel Unboxed array representation
--   (computation is done in parallel).</li>
--   <li><a>RSS</a> - Repa Sequential Storable array representation
--   (computation is done sequentially).</li>
--   <li><a>RPS</a> - Repa Parallel Storable array representation
--   (computation is done in parallel).</li>
--   </ul>
--   
--   Images with <a>RSU</a>, <a>RSS</a>, <a>RPU</a> and <a>RPS</a> types,
--   most of the time, hold functions rather than an actual data, this way
--   computation can be fused together, and later changed to <a>VU</a> or
--   <a>VS</a> using <a>toManifest</a>, which in turn performs the fused
--   computation. If at any time computation needs to be forced,
--   <a>compute</a> can be used for that purpose.
--   
--   Many of the function names exported by this module will clash with the
--   ones from <a>Prelude</a>, hence it can be more convenient to import
--   like this:
--   
--   <pre>
--   import Prelude as P
--   import Graphics.Image as I
--   </pre>
module Graphics.Image

-- | Create an image with a specified representation and pixels of
--   <a>Double</a> precision. Note, that it is essential for <a>Double</a>
--   precision pixels to keep values normalized in the <tt>[0, 1]</tt>
--   range in order for an image to be written to file properly.
--   
--   <pre>
--   &gt;&gt;&gt; let grad_gray = makeImageR VU (200, 200) (\(i, j) -&gt; PixelY (fromIntegral i) / 200 * (fromIntegral j) / 200)
--   </pre>
--   
--   Because all <a>Pixel</a>s and <a>Image</a>s are installed into
--   <a>Num</a>, above is equivalent to:
--   
--   <pre>
--   &gt;&gt;&gt; let grad_gray = makeImageR RPU (200, 200) (\(i, j) -&gt; PixelY $ fromIntegral (i*j)) / (200*200)
--   
--   &gt;&gt;&gt; writeImage "images/grad_gray.png" grad_gray
--   </pre>
--   
--   Creating color images is just as easy.
--   
--   <pre>
--   &gt;&gt;&gt; let grad_color = makeImageR VU (200, 200) (\(i, j) -&gt; PixelRGB (fromIntegral i) (fromIntegral j) (fromIntegral (i + j))) / 400
--   
--   &gt;&gt;&gt; writeImage "images/grad_color.png" grad_color
--   </pre>
--   
makeImageR :: Array arr cs e => arr -> (Int, Int) -> ((Int, Int) -> Pixel cs e) -> Image arr cs e

-- | 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 <a>fromLists</a> 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 <tt>m</tt> rows, while the
--   length of inner lists - <tt>n</tt> columns. All of the inner lists
--   must be the same length and greater than <tt>0</tt>.
--   
--   <pre>
--   &gt;&gt;&gt; fromLists [[PixelY (fromIntegral (i*j) / 60000) | j &lt;- [1..300]] | i &lt;- [1..200]]
--   &lt;Image VectorUnboxed Y (Double): 200x300&gt;
--   </pre>
--   
fromLists :: Array arr cs e => [[Pixel cs e]] -> Image arr cs e

-- | Generates a nested list of pixels from an image.
--   
--   <pre>
--   img == fromLists (toLists img)
--   </pre>
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 <tt>Alpha</tt> 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 <tt>Alpha</tt> channel.
readImageRGBA :: Array arr RGBA Double => arr -> FilePath -> IO (Image arr RGBA Double)

-- | Just like <a>readImage</a>, this function will guess an output file
--   format from the extension and write to file any image that is in one
--   of <a>Y</a>, <a>YA</a>, <a>RGB</a> or <a>RGBA</a> color spaces with
--   <a>Double</a> 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 <a>PNG</a> format, an (<a>Image</a>
--   <tt>arr</tt> <a>RGBA</a> <a>Double</a>) would be written as
--   <tt>RGBA16</tt>, hence preserving transparency and using highest
--   supported precision <a>Word16</a>. At the same time, writing that
--   image in <a>GIF</a> format would save it in <tt>RGB8</tt>, since
--   <a>Word8</a> is the highest precision <a>GIF</a> 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.
--   
--   <pre>
--   &gt;&gt;&gt; frog &lt;- readImageRGB VU "images/frog.jpg"
--   
--   &gt;&gt;&gt; frog
--   &lt;Image VectorUnboxed RGB (Double): 200x320&gt;
--   
--   &gt;&gt;&gt; rows frog
--   200
--   </pre>
rows :: BaseArray arr cs e => Image arr cs e -> Int

-- | Get the number of columns in an image.
--   
--   <pre>
--   &gt;&gt;&gt; frog &lt;- readImageRGB VU "images/frog.jpg"
--   
--   &gt;&gt;&gt; frog
--   &lt;Image VectorUnboxed RGB (Double): 200x320&gt;
--   
--   &gt;&gt;&gt; cols frog
--   320
--   </pre>
cols :: BaseArray arr cs e => Image arr cs e -> Int

-- | Get dimensions of an image.
--   
--   <pre>
--   &gt;&gt;&gt; frog &lt;- readImageRGB VU "images/frog.jpg"
--   
--   &gt;&gt;&gt; frog
--   &lt;Image VectorUnboxed RGB (Double): 200x320&gt;
--   
--   &gt;&gt;&gt; dims frog
--   (200,320)
--   </pre>
dims :: BaseArray arr cs e => Image arr cs e -> (Int, Int)

-- | Get a pixel at <tt>i</tt>-th and <tt>j</tt>-th location.
--   
--   <pre>
--   &gt;&gt;&gt; let grad_gray = makeImage (200, 200) (\(i, j) -&gt; PixelY $ fromIntegral (i*j)) / (200*200)
--   
--   &gt;&gt;&gt; index grad_gray (20, 30) == PixelY ((20*30) / (200*200))
--   True
--   </pre>
index :: MArray arr cs e => Image arr cs e -> (Int, Int) -> Pixel cs e

-- | Image indexing function that returns <tt><a>Nothing</a></tt> if index
--   is out of bounds, <tt><a>Just</a> px</tt> 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 <tt>[0, 1]</tt>.
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 <a>Float</a> or <a>Double</a> precision.
eqTol :: (Array arr X 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
