Safe Haskell | None |
---|---|

Language | Haskell2010 |

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

## Synopsis

- sub :: Num x => (x, x) -> (x, x) -> (x, x)
- dotProduct :: Num x => (x, x) -> (x, x) -> x
- fromIntegralP :: (Integral x, Num y) => (x, x) -> (y, y)
- mag :: Floating x => (x, x) -> x
- hough :: forall arr. (MArray arr Y Double, Array arr Y Double, Array arr Y Word8) => Image arr Y Double -> Int -> Int -> Image arr Y Word8

# Documentation

sub :: Num x => (x, x) -> (x, x) -> (x, x) Source #

Some helper functions : | Trivial function for subtracting co-ordinate pairs

dotProduct :: Num x => (x, x) -> (x, x) -> x Source #

Compute the sum of squares or dot product of a given pair of co-ordinates

fromIntegralP :: (Integral x, Num y) => (x, x) -> (y, y) Source #

Conversion of pair fromIntegral

hough :: forall arr. (MArray arr Y Double, Array arr Y Double, Array arr Y Word8) => Image arr Y Double -> Int -> Int -> Image arr Y Word8 Source #

`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 filter to the results of the transform, it is possible to extract the locations of the lines in the original image.

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 yield thetaSz distSz`

`>>>`

`writeImage "test.png" houghImage`