Skip to content

Commit

Permalink
Modified shrink such that it now will work with Images that have a Co…
Browse files Browse the repository at this point in the history
…mplexPixel type and return the same type of image. This seems more intuitive and allow users to use it with GrayImages and get GrayImages back. If the user want to use it specifically with Complex values, they will already have a ComplexImage and thus it is a non issue and the type does not need to be coerced.
  • Loading branch information
jcollard committed Jul 29, 2013
1 parent e6662ae commit 95272db
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
5 changes: 3 additions & 2 deletions Data/Image/Boxed.hs
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ instance BinaryPixel Gray where
instance CI.ComplexPixel Gray where
type Value Gray = Double
toComplex i = i C.:+ 0.0
fromComplex (r C.:+ i) = r

instance Monoid Gray where
mempty = 0.0
Expand Down Expand Up @@ -279,6 +280,7 @@ instance DisplayFormat ComplexImage where
instance CI.ComplexPixel Complex where
type Value Complex = Double
toComplex = id
fromComplex = id

complexImageToColorImage :: ComplexImage -> ColorImage
complexImageToColorImage img = fmap rgb img where
Expand Down Expand Up @@ -593,8 +595,7 @@ complexImageToRectangular = CI.complexImageToRectangular
-}
shrink :: (Image img,
CI.ComplexPixel (Pixel img),
CI.Value (Pixel img) ~ Double) => Double -> img -> ComplexImage
CI.ComplexPixel (Pixel img)) => (CI.Value (Pixel img)) -> img -> img
shrink = CI.shrink

{-| Given an image whose pixels can be converted to a complex value,
Expand Down
7 changes: 3 additions & 4 deletions Data/Image/Complex.hs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import qualified Data.Vector as V
class RealFloat (Value px) => ComplexPixel px where
type Value px :: *
toComplex :: px -> C.Complex (Value px)
fromComplex :: C.Complex (Value px) -> px

{-| Given a positive integer m, a positive integer n, and a function
returning a pixel value, makeFilter returns an image with m rows
Expand Down Expand Up @@ -274,12 +275,10 @@ complexImageToRectangular img = (realPart img, imagPart img)
-}
shrink :: (Image img,
ComplexPixel (Pixel img),
Image img',
Pixel img' ~ C.Complex (Value (Pixel img))) => (Value (Pixel img)) -> img -> img'
ComplexPixel (Pixel img)) => (Value (Pixel img)) -> img -> img
shrink x img@(dimensions -> (rows, cols)) =
makeImage rows cols shrink' where
shrink' r c = helper px where
shrink' r c = fromComplex . helper $ px where
px = toComplex . ref img r $ c
helper px
| (C.magnitude px) < x = 0.0 C.:+ 0.0
Expand Down
5 changes: 4 additions & 1 deletion changes.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
Version #: 0.2.1.5
Version #: 0.3.1.5
^ ^ ^ ^
| | | --- Bug fixes / improvements to existing code
| | ----- New functions / features
| |------ Break in backwards compatibilty
|-------- Change in stability

unm-hip-0.3.1.5:
- Modified shrink such that it now will work with Images that have a ComplexPixel type and return the same type of image. This seems more intuitive and allow users to use it with GrayImages and get GrayImages back. If the user want to use it specifically with Complex values, they will already have a ComplexImage and thus it is a non issue and the type does not need to be coerced.

unm-hip-0.2.1.5
- fixed a bug in normalize that was producing images with NaN pixel values
- fixed a bug in shrink that was producing an infinite loop. Resulting in the type signature changing
Expand Down
4 changes: 2 additions & 2 deletions unm-hip.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Name: unm-hip
Version: 0.1.1.5
Version: 0.3.1.5
License: GPL
License-File: LICENSE
Author: Joseph Collard, Stephen Patel, Lance Williams
Expand All @@ -11,7 +11,7 @@ Description: The University of New Mexico's Haskell Image Processing libra
.
[Changes]
.
* Fixed a bug in normalize that was producing images with NaN pixel values
* Modified shrink such that it now will work with Images that have a ComplexPixel type and return the same type of image. This seems more intuitive and allow users to use it with GrayImages and get GrayImages back. If the user want to use it specifically with Complex values, they will already have a ComplexImage and thus it is a non issue and the type does not need to be coerced.
Cabal-Version: >= 1.6
Build-Type: Simple

Expand Down

0 comments on commit 95272db

Please sign in to comment.