opencv-0.0.2.1: Haskell binding to OpenCV-3.x

Safe HaskellNone
LanguageHaskell2010

OpenCV.Photo

Synopsis

Documentation

data InpaintingMethod Source #

Constructors

InpaintNavierStokes

Navier-Stokes based method.

InpaintTelea

Method by Alexandru Telea.

decolor Source #

Arguments

:: Mat (S [h, w]) (S 3) (S Word8)

Input image.

-> CvExcept (Mat (S [h, w]) (S 1) (S Word8), Mat (S [h, w]) (S 3) (S Word8))

Output images.

Perform decolor

Decolor a color image to a grayscale (1 channel) and a color boosted image (3 channel)

Example:

decolorImg
    :: forall h h2 w w2 c d
     . ( Mat (ShapeT [h, w]) ('S c) ('S d) ~ Kodak_512x341
       , h2 ~ ((*) h 2)
       , w2 ~ ((*) w 2)
       )
    => Mat ('S ['S h2, 'S w2]) ('S c) ('S d)
decolorImg = exceptError $ do
    (bikesGray, boost) <- decolor bikes_512x341
    colorGray <- cvtColor gray bgr bikesGray
    withMatM
      (Proxy :: Proxy [h2, w2])
      (Proxy :: Proxy c)
      (Proxy :: Proxy d)
      white $ \imgM -> do
        matCopyToM imgM (V2 0 0) bikes_512x341 Nothing
        matCopyToM imgM (V2 0 h) colorGray Nothing
        matCopyToM imgM (V2 w h) boost  Nothing
  where
    w = fromInteger $ natVal (Proxy :: Proxy w)
    h = fromInteger $ natVal (Proxy :: Proxy h)

inpaint Source #

Arguments

:: channels `In` [1, 3] 
=> Double

inpaintRadius - Radius of a circular neighborhood of each point inpainted that is considered by the algorithm.

-> InpaintingMethod 
-> Mat (S [h, w]) (S channels) (S Word8)

Input image.

-> Mat (S [h, w]) (S 1) (S Word8)

Inpainting mask.

-> CvExcept (Mat (S [h, w]) (S channels) (S Word8))

Output image.

Restores the selected region in an image using the region neighborhood.

Example:

inpaintImg
    :: forall h h2 w w2 c d
     . ( Mat (ShapeT [h, w]) ('S c) ('S d) ~ Kodak_512x341
       , h2 ~ ((*) h 2)
       , w2 ~ ((*) w 2)
       )
    => Mat ('S ['S h2, 'S w2]) ('S c) ('S d)
inpaintImg = exceptError $ do
    maskInv <- bitwiseNot mask
    maskBgr <- cvtColor gray bgr maskInv
    damaged <- bitwiseAnd bikes_512x341 maskBgr
    repairedNS <- inpaint 3 InpaintNavierStokes damaged mask
    repairedT  <- inpaint 3 InpaintTelea        damaged mask
    withMatM
      (Proxy :: Proxy [h2, w2])
      (Proxy :: Proxy c)
      (Proxy :: Proxy d)
      black $ \imgM -> do
        matCopyToM imgM (V2 0 0) damaged Nothing
        matCopyToM imgM (V2 w 0) maskBgr Nothing
        matCopyToM imgM (V2 0 h) repairedNS Nothing
        matCopyToM imgM (V2 w h) repairedT  Nothing
  where
    mask = damageMask

    w = fromInteger $ natVal (Proxy :: Proxy w)
    h = fromInteger $ natVal (Proxy :: Proxy h)

denoise_TVL1 Source #

Arguments

:: Double

details more is more 2

-> Int32

Number of iterations that the algorithm will run

-> Vector (Mat (S [h, w]) (S 1) (S Word8))

Vector of odd number of input 8-bit 3-channel images.

-> CvExcept (Mat (S [h, w]) (S 1) (S Word8))

Output image same size and type as input.

Perform denoise_TVL1

Example:

denoise_TVL1Img
    :: forall h w w2 c d
     . ( Mat (ShapeT [h, w]) ('S c) ('S d) ~ Lenna_512x512
       , w2 ~ ((*) w 2)
       )
    => Mat ('S ['S h, 'S w2]) ('S c) ('S d)
denoise_TVL1Img = exceptError $ do
    denoised <- matChannelMapM (denoise_TVL1 2 50 . V.singleton) lenna_512x512
    withMatM
      (Proxy :: Proxy [h, w2])
      (Proxy :: Proxy c)
      (Proxy :: Proxy d)
      black $ \imgM -> do
        matCopyToM imgM (V2 0 0) lenna_512x512 Nothing
        matCopyToM imgM (V2 w 0) denoised Nothing
  where
    w = fromInteger $ natVal (Proxy :: Proxy w)

fastNlMeansDenoisingColored Source #

Arguments

:: Double

Parameter regulating filter strength for luminance component. Bigger h value perfectly removes noise but also removes image details, smaller h value preserves details but also preserves some noise

-> Double

The same as h but for color components. For most images value equals 10 will be enough to remove colored noise and do not distort colors

-> Int32

templateWindowSize Size in pixels of the template patch that is used to compute weights. Should be odd. Recommended value 7 pixels

-> Int32

searchWindowSize. Size in pixels of the window that is used to compute weighted average for given pixel. Should be odd. Affect performance linearly: greater searchWindowsSize - greater denoising time. Recommended value 21 pixels

-> Mat (S [h, w]) (S 3) (S Word8)

Input image 8-bit 3-channel image.

-> CvExcept (Mat (S [h, w]) (S 3) (S Word8))

Output image same size and type as input.

Perform fastNlMeansDenoising function for colored images. Denoising is not per channel but in a different colour space

Example:

fastNlMeansDenoisingColoredImg
    :: forall h w w2 c d
     . ( Mat (ShapeT [h, w]) ('S c) ('S d) ~ Lenna_512x512
       , w2 ~ ((*) w 2)
       )
    => Mat ('S ['S h, 'S w2]) ('S c) ('S d)
fastNlMeansDenoisingColoredImg = exceptError $ do
    denoised <- fastNlMeansDenoisingColored 3 10 7 21 lenna_512x512
    withMatM
      (Proxy :: Proxy [h, w2])
      (Proxy :: Proxy c)
      (Proxy :: Proxy d)
      black $ \imgM -> do
        matCopyToM imgM (V2 0 0) lenna_512x512 Nothing
        matCopyToM imgM (V2 w 0) denoised Nothing
  where
    w = fromInteger $ natVal (Proxy :: Proxy w)

fastNlMeansDenoisingColoredMulti Source #

Arguments

:: Double

Parameter regulating filter strength for luminance component. Bigger h value perfectly removes noise but also removes image details, smaller h value preserves details but also preserves some noise

-> Double

The same as h but for color components. For most images value equals 10 will be enough to remove colored noise and do not distort colors

-> Int32

templateWindowSize Size in pixels of the template patch that is used to compute weights. Should be odd. Recommended value 7 pixels

-> Int32

searchWindowSize. Size in pixels of the window that is used to compute weighted average for given pixel. Should be odd. Affect performance linearly: greater searchWindowsSize - greater denoising time. Recommended value 21 pixels

-> Vector (Mat (S [h, w]) (S 3) (S Word8))

Vector of odd number of input 8-bit 3-channel images.

-> CvExcept (Mat (S [h, w]) (S 3) (S Word8))

Output image same size and type as input.

Perform fastNlMeansDenoisingColoredMulti function for colored images. Denoising is not pre channel but in a different colour space. This wrapper differs from the original OpenCV version by using all input images and denoising the middle one. The original version would allow to have some arbitrary length vector and slide window over it. As we have to copy the haskell vector before we can use it as `std::vector` on the cpp side it is easier to trim the vector before sending and use all frames.

Example:

fastNlMeansDenoisingColoredMultiImg
    :: forall h w w2 c d
     . ( Mat (ShapeT [h, w]) ('S c) ('S d) ~ Lenna_512x512
       , w2 ~ ((*) w 2)
       )
    => Mat ('S ['S h, 'S w2]) ('S c) ('S d)
fastNlMeansDenoisingColoredMultiImg = exceptError $ do
    denoised <- fastNlMeansDenoisingColoredMulti 3 10 7 21 (V.singleton lenna_512x512)
    withMatM
      (Proxy :: Proxy [h, w2])
      (Proxy :: Proxy c)
      (Proxy :: Proxy d)
      black $ \imgM -> do
        matCopyToM imgM (V2 0 0) lenna_512x512 Nothing
        matCopyToM imgM (V2 w 0) denoised Nothing
  where
    w = fromInteger $ natVal (Proxy :: Proxy w)