hip 1.0.1.1 → 1.0.1.2
raw patch · 9 files changed
+62/−34 lines, 9 filesbinary-addedPVP: minor bump suggested
API additions: PVP suggests at least a minor version bump
API changes (from Hackage documentation)
+ Graphics.Image: toLists :: ManifestArray arr cs e => Image arr cs e -> [[Pixel cs e]]
Files
- hip.cabal +1/−1
- images/centaurus_and_cluster.jpg binary
- images/frogY.jpg binary
- images/frog_sobel.jpg binary
- src/Graphics/Image.hs +23/−15
- src/Graphics/Image/IO/External/JuicyPixels.hs +6/−1
- src/Graphics/Image/Interface.hs +16/−11
- src/Graphics/Image/Processing/Convolution.hs +10/−0
- src/Graphics/Image/Processing/Geometric.hs +6/−6
hip.cabal view
@@ -1,5 +1,5 @@ Name: hip-Version: 1.0.1.1+Version: 1.0.1.2 License: BSD3 License-File: LICENSE Author: Alexey Kuleshevich
+ images/centaurus_and_cluster.jpg view
binary file changed (absent → 211374 bytes)
+ images/frogY.jpg view
binary file changed (absent → 41886 bytes)
+ images/frog_sobel.jpg view
binary file changed (absent → 43400 bytes)
src/Graphics/Image.hs view
@@ -45,8 +45,8 @@ -- -- Just as it is mentioned above, Vector representation is a default one, so in -- order to create images with Repa representation--- "Graphics.Image.Interface.Repa" module can be used. It should be imported as--- qualified, since it contains image generating functions with same names as+-- "Graphics.Image.Interface.Repa" module should be used. It has to be imported+-- as qualified, since it contains image generating functions with same names as -- here. -- -- Many of the function names exported by this module will clash with the ones@@ -71,7 +71,7 @@ -- -- @ makeImage (256, 256) (PixelY . fromIntegral . fst) :: Image RP Y Word8 @ --- makeImage, fromLists,+ makeImage, fromLists, toLists, -- * IO -- ** Reading -- | Read any supported image file into an 'Image' with 'VU' (Vector Unboxed)@@ -115,13 +115,13 @@ import Graphics.Image.Processing+import Graphics.Image.Processing.Binary import Graphics.Image.Processing.Complex import Graphics.Image.Processing.Geometric import Graphics.Image.IO.Histogram - -- | Get the number of rows in an image. -- -- >>> frog <- readImageRGB "images/frog.jpg"@@ -186,24 +186,31 @@ {-# INLINE normalize #-} +-- | Generates a nested list of pixels from an image.+--+-- @ img == fromLists (toLists img) @+--+toLists :: ManifestArray arr cs e => Image arr cs e -> [[Pixel cs e]]+toLists img = [[index img (i, j) | j <- [0..cols img - 1]] | i <- [0..rows img - 1]]+ -- $colorspace -- Here is a list of default Pixels with their respective constructors: -- -- @--- * __'Pixel' 'Y' e = PixelY e__ - Luma, also commonly denoted as __Y'__.--- * __'Pixel' 'YA' e = PixelYA e__ - Luma with alpha.--- * __'Pixel' 'RGB' e = PixelRGB e__ - Red, Green and Blue.--- * __'Pixel' 'RGBA' e = PixelRGBA e__ - RGB with alpha--- * __'Pixel' 'HSI' e = PixelHSI e__ - Hue, Saturation and Intensity.--- * __'Pixel' 'HSIA' e = PixelHSIA e__ - HSI with alpha--- * __'Pixel' 'CMYK' e = PixelCMYK e__ - Cyan, Magenta, Yellow and Key (Black).--- * __'Pixel' 'CMYKA' e = PixelCMYKA e__ - CMYK with alpha.--- * __'Pixel' 'YCbCr' e = PixelYCbCr e__ - Luma, blue-difference and red-difference chromas.--- * __'Pixel' 'YCbCrA' e = PixelYCbCrA e__ - YCbCr with alpha.+-- * __'Pixel' 'Y' e = PixelY y__ - Luma, also commonly denoted as __Y'__.+-- * __'Pixel' 'YA' e = PixelYA y a__ - Luma with alpha.+-- * __'Pixel' 'RGB' e = PixelRGB r g b__ - Red, Green and Blue.+-- * __'Pixel' 'RGBA' e = PixelRGBA r g b a__ - RGB with alpha+-- * __'Pixel' 'HSI' e = PixelHSI h s i__ - Hue, Saturation and Intensity.+-- * __'Pixel' 'HSIA' e = PixelHSIA h s i a__ - HSI with alpha+-- * __'Pixel' 'CMYK' e = PixelCMYK c m y k__ - Cyan, Magenta, Yellow and Key (Black).+-- * __'Pixel' 'CMYKA' e = PixelCMYKA c m y k a__ - CMYK with alpha.+-- * __'Pixel' 'YCbCr' e = PixelYCbCr y cb cr__ - Luma, blue-difference and red-difference chromas.+-- * __'Pixel' 'YCbCrA' e = PixelYCbCrA y cb cr a__ - YCbCr with alpha. -- ------------------------------------------------------------------------------------------ -- * __'Pixel' 'Binary' 'Bit' = 'on' | 'off'__ - Bi-tonal. -- * __'Pixel' cs ('Complex' e) = ('Pixel' cs e) '+:' ('Pixel' cs e)__ - Complex pixels with any color space.--- * __'Pixel' 'Gray' e = PixelGray e__ - Used for separating channels from other color spaces.+-- * __'Pixel' 'Gray' e = PixelGray g__ - Used for separating channels from other color spaces. -- @ -- -- Every 'Pixel' is an instance of 'Functor', 'Applicative', 'F.Foldable' and@@ -211,3 +218,4 @@ -- -- All of the functionality related to every 'ColorSpace' is re-exported by -- "Graphics.Image.Types" module.+
src/Graphics/Image/IO/External/JuicyPixels.hs view
@@ -12,7 +12,12 @@ module Graphics.Image.IO.External.JuicyPixels ( BMP(..), GIF(..), JP.GifDelay, JP.GifLooping(..), JP.PaletteOptions(..), JP.PaletteCreationMethod(..),- HDR(..), JPG(..), PNG(..), TGA(..), TIF(..)+ HDR(..),+ JPG(..),+ PNG(..),+ TGA(..),+ TIF(..),+ SaveOption(..), ) where import GHC.Float
src/Graphics/Image/Interface.hs view
@@ -164,7 +164,7 @@ -- ^ A function that takes a pixel of a source image and returns a pixel -- for the result image a the same location. -> Image arr cs' e' -- ^ Source image.- -> Image arr cs e -- ^ Result image.+ -> Image arr cs e -- ^ Result image. -- | Map an index aware function over each pixel in an image. imap :: Array arr cs' e' =>@@ -288,16 +288,20 @@ mdims :: MImage st arr cs e -> (Int, Int) -- | Yield a mutable copy of an image.- thaw :: (Functor m, PrimMonad m) => Image arr cs e -> m (MImage (PrimState m) arr cs e)+ thaw :: (Functor m, PrimMonad m) =>+ Image arr cs e -> m (MImage (PrimState m) arr cs e) -- | Yield an immutable copy of an image.- freeze :: (Functor m, PrimMonad m) => MImage (PrimState m) arr cs e -> m (Image arr cs e)+ freeze :: (Functor m, PrimMonad m) =>+ MImage (PrimState m) arr cs e -> m (Image arr cs e) - -- | Create a mutable image with given dimensions. Pixels are uninitialized.- new :: (Functor m, PrimMonad m) => (Int, Int) -> m (MImage (PrimState m) arr cs e)+ -- | Create a mutable image with given dimensions. Pixels are likely uninitialized.+ new :: (Functor m, PrimMonad m) =>+ (Int, Int) -> m (MImage (PrimState m) arr cs e) -- | Yield the pixel at a given location.- read :: (Functor m, PrimMonad m) => MImage (PrimState m) arr cs e -> (Int, Int) -> m (Pixel cs e)+ read :: (Functor m, PrimMonad m) =>+ MImage (PrimState m) arr cs e -> (Int, Int) -> m (Pixel cs e) -- | Set a pixel at a given location. write :: (Functor m, PrimMonad m) =>@@ -318,7 +322,7 @@ -> Image arr cs e --- | Changing to the same array representation as before is disabled and `changeTo`+-- | Changing to the same array representation as before is disabled and `exchange` -- will behave simply as an identitity function. instance Exchangable arr arr where @@ -327,9 +331,10 @@ --- | Approach to be used near the border during transformations, which, besides a pixel--- of interest, also use it's neighbors, consequently going out of bounds at the--- edges of an image.+-- | 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 !px -- ^ Fill in a constant pixel. --@@ -447,7 +452,7 @@ {-# INLINE signum #-} fromInteger = pure . fromInteger- {-# INLINE fromInteger#-}+ {-# INLINE fromInteger #-} instance (ColorSpace cs, Fractional e) => Fractional (Pixel cs e) where
src/Graphics/Image/Processing/Convolution.hs view
@@ -43,6 +43,16 @@ {-# INLINE convolve'' #-} -- | Convolution of an image using a kernel. Border resolution technique is required.+--+-- Example using <https://en.wikipedia.org/wiki/Sobel_operator Sobel operator>:+--+-- >>> frog <- readImageY "frog.jpg"+-- >>> let frogX = convolve Edge (fromLists [[-1, 0, 1], [-2, 0, 2], [-1, 0, 1]]) frog+-- >>> let frogY = convolve Edge (fromLists [[-1,-2,-1], [ 0, 0, 0], [ 1, 2, 1]]) frog+-- >>> displayImage $ normalize $ sqrt (frogX ^ 2 + frogY ^ 2)+--+-- <<images/frogY.jpg>> <<images/frog_sobel.jpg>>+-- convolve :: ManifestArray arr cs e => Border (Pixel cs e) -- ^ Approach to be used near the borders. -> Image arr cs e -- ^ Kernel image.
src/Graphics/Image/Processing/Geometric.hs view
@@ -137,7 +137,7 @@ -- | Flip an image vertically. -- -- >>> frog <- readImageRGB "images/frog.jpg"--- >>> writeImage "images/frog_flipV.jpg" (computeS $ flipV frog) +-- >>> writeImage "images/frog_flipV.jpg" $ flipV frog -- -- <<images/frog.jpg>> <<images/frog_flipV.jpg>> --@@ -149,7 +149,7 @@ -- | Flip an image horizontally. -- -- >>> frog <- readImageRGB "images/frog.jpg"--- >>> writeImage "images/frog_flipH.jpg" (flipH frog) +-- >>> writeImage "images/frog_flipH.jpg" $ flipH frog -- -- <<images/frog.jpg>> <<images/frog_flipH.jpg>> --@@ -161,7 +161,7 @@ -- | Rotate an image clockwise by 90°. -- -- >>> frog <- readImageRGB "images/frog.jpg"--- >>> writeImage "images/frog_rotate90.jpg" (rotate90 frog) +-- >>> writeImage "images/frog_rotate90.jpg" $ rotate90 frog -- -- <<images/frog.jpg>> <<images/frog_rotate90.jpg>> --@@ -173,7 +173,7 @@ -- | Rotate an image by 180°. -- -- >>> frog <- readImageRGB "images/frog.jpg"--- >>> writeImage "images/frog_rotate180.jpg" (rotate180 frog) +-- >>> writeImage "images/frog_rotate180.jpg" $ rotate180 frog -- -- <<images/frog.jpg>> <<images/frog_rotate180.jpg>> --@@ -185,7 +185,7 @@ -- | Rotate an image clockwise by 270°. -- -- >>> frog <- readImageRGB "images/frog.jpg"--- >>> writeImage "images/frog_rotate270.jpg" (rotate270 frog) +-- >>> writeImage "images/frog_rotate270.jpg" $ rotate270 frog -- -- <<images/frog.jpg>> <<images/frog_rotate270.jpg>> --@@ -230,7 +230,7 @@ -- | Resize an image using an interpolation method. -- -- >>> frog <- readImageRGB "images/frog.jpg"--- >>> writeImage "images/frog_resize.jpg" (resize (Bilinear Edge) (100, 640) frog)+-- >>> writeImage "images/frog_resize.jpg" $ resize (Bilinear Edge) (100, 640) frog -- -- <<images/frog_resize.jpg>> --