Skip to content

Commit

Permalink
Add warnings to buggy modules. Update changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
lehins committed Mar 1, 2020
1 parent 40b4e78 commit ee1a68b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 15 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
1.5.5.0
=======

* Ability to encode animated gifs

1.5.4.0
=======

* Addition of `disable-chart` flag
* Bunch of semi-functional stuff from GSoC 2018

1.5.2.0
1.5.3.0
=======

* Fixed FFT performace issue
Expand Down
2 changes: 2 additions & 0 deletions src/Graphics/Image/Processing/Ahe.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

-- | Adaptive histogram equalization is used to improve contrast in images.
-- It adjusts image intensity in small regions (neighborhood) in the image.
--
-- /__Warning__/ - This module is experimental and likely doesn't work as expected
module Graphics.Image.Processing.Ahe where

import Control.Monad (forM_, when)
Expand Down
29 changes: 15 additions & 14 deletions src/Graphics/Image/Processing/Hough.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE ScopedTypeVariables #-}

-- | Hough Transform is used as a part of feature extraction in images.
-- | Hough Transform is used as a part of feature extraction in images.
-- It is a tool that makes it far easier to identify straight lines in
-- the source image, whatever their orientation.
--
-- /__Warning__/ - This module is experimental and likely doesn't work as expected
module Graphics.Image.Processing.Hough where

import Control.Monad (forM_, when)
Expand All @@ -18,7 +20,7 @@ import Graphics.Image.Interface as I
import Graphics.Image.Types as IP

-- | Some helper functions :
-- | Trivial function for subtracting co-ordinate pairs
-- | Trivial function for subtracting co-ordinate pairs
sub :: Num x => (x, x) -> (x, x) -> (x, x)
sub (x1, y1) (x2, y2) = (x1 - x2, y1 - y2)

Expand All @@ -34,25 +36,25 @@ fromIntegralP (x1, y1) = (fromIntegral x1, fromIntegral y1)
mag :: Floating x => (x, x) -> x
mag x = sqrt (dotProduct x x)

-- | 'hough' computes the Linear Hough Transform and maps each point in the target image, (ρ, θ)
-- to the average color of the pixels on the corresponding line of the source image (x,y) - space,
-- where the line corresponds to points of the form (xcosθ + ysinθ = ρ(rho)).
-- | 'hough' computes the Linear Hough Transform and maps each point in the target image, (ρ, θ)
-- to the average color of the pixels on the corresponding line of the source image (x,y) - space,
-- where the line corresponds to points of the form (xcosθ + ysinθ = ρ(rho)).
--
-- The idea is that where there is a straight line in the original image, it corresponds to a
-- bright (or dark, depending on the color of the background field) spot; by applying a suitable
-- The idea is that where there is a straight line in the original image, it corresponds to a
-- bright (or dark, depending on the color of the background field) spot; by applying a suitable
-- filter to the results of the transform, it is possible to extract the locations of the lines in the original image.
--
-- <<images/yield.jpg>> <<images/yield_hough.png>>
--
-- Usage :
--
-- >>> frog <- readImageRGB VU "yield.jpg"
-- Usage :
--
-- >>> yield <- readImageRGB VU "yield.jpg"
-- >>> input1 <- getLine
-- >>> input2 <- getLine
-- >>> let thetaSz = (P.read input1 :: Int)
-- >>> let distSz = (P.read input2 :: Int)
-- >>> let houghImage :: Image VU RGB Double
-- >>> houghImage = hough frog thetaSz distSz
-- >>> houghImage = hough yield thetaSz distSz
-- >>> writeImage "test.png" houghImage
--
hough
Expand Down Expand Up @@ -80,7 +82,7 @@ hough image thetaSz distSz = I.map (fmap toWord8) hImage
slopeMap = [ ((x, y), slope x y) | x <- [0 .. widthMax], y <- [0 .. heightMax] ]

distMax :: Double -- Compute Maximum distance
distMax = (sqrt . fromIntegral $ (heightMax + 1) ^ (2 :: Int) + (widthMax + 1) ^ (2 :: Int)) / 2
distMax = (sqrt . fromIntegral $ (heightMax + 1) ^ (2 :: Int) + (widthMax + 1) ^ (2 :: Int)) / 2

accBin = runSTArray $ -- Core part of Algo begins here. Working in a safe way with a mutable array.
do arr <- newArray ((0, 0), (thetaSz, distSz)) (0 :: Double) -- Build a new array, with every element initialised to the supplied value.
Expand All @@ -99,11 +101,10 @@ hough image thetaSz distSz = I.map (fmap toWord8) hImage
writeArray arr idx (old + 1)
return arr

maxAcc = F.maximum accBin
maxAcc = F.maximum accBin
hTransform (x, y) =
let l = 255 - truncate ((accBin ! (x, y)) / maxAcc * 255) -- pixel generating function
in PixelY l

hImage :: Image arr Y Word8
hImage = makeImage (thetaSz, distSz) hTransform

0 comments on commit ee1a68b

Please sign in to comment.