From 95272db59ea4163f5541a75306df4f56fe031a4e Mon Sep 17 00:00:00 2001 From: jcollard Date: Mon, 29 Jul 2013 12:27:23 -0600 Subject: [PATCH] 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. --- Data/Image/Boxed.hs | 5 +++-- Data/Image/Complex.hs | 7 +++---- changes.txt | 5 ++++- unm-hip.cabal | 4 ++-- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Data/Image/Boxed.hs b/Data/Image/Boxed.hs index 91e23d0..4d9bdcd 100644 --- a/Data/Image/Boxed.hs +++ b/Data/Image/Boxed.hs @@ -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 @@ -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 @@ -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, diff --git a/Data/Image/Complex.hs b/Data/Image/Complex.hs index 5ba4399..0104ec2 100644 --- a/Data/Image/Complex.hs +++ b/Data/Image/Complex.hs @@ -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 @@ -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 diff --git a/changes.txt b/changes.txt index 9fbebd2..791d6d2 100644 --- a/changes.txt +++ b/changes.txt @@ -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 diff --git a/unm-hip.cabal b/unm-hip.cabal index 04ebd1f..58b4bba 100644 --- a/unm-hip.cabal +++ b/unm-hip.cabal @@ -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 @@ -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