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

Safe HaskellNone
LanguageHaskell2010

OpenCV.ImgProc.ColorMaps

Synopsis

Documentation

applyColorMap :: ColorMap -> Mat shape (S 1) (S Word8) -> CvExcept (Mat shape (S 3) (S Word8)) Source #

Applies a GNU Octave/MATLAB equivalent colormap on a given image

The human perception isn’t built for observing fine changes in grayscale images. Human eyes are more sensitive to observing changes between colors, so you often need to recolor your grayscale images to get a clue about them. OpenCV now comes with various colormaps to enhance the visualization in your computer vision application.

Example:

grayscaleImg
    :: forall (height :: Nat) (width :: Nat) depth
     . (height ~ 30, width ~ 256, depth ~ Word8)
    => Mat (ShapeT [height, width]) ('S 1) ('S depth)
grayscaleImg = exceptError $
    matFromFunc
      (Proxy :: Proxy [height, width])
      (Proxy :: Proxy 1)
      (Proxy :: Proxy depth)
      grayscale
  where
    grayscale :: [Int] -> Int -> Word8
    grayscale [_y, x] 0 = fromIntegral x
    grayscale _pos _channel = error "impossible"

type ColorMapImg = Mat (ShapeT [30, 256]) ('S 3) ('S Word8)

mkColorMapImg :: ColorMap -> ColorMapImg
mkColorMapImg cmap = exceptError $ applyColorMap cmap grayscaleImg

colorMapAutumImg   :: ColorMapImg
colorMapBoneImg    :: ColorMapImg
colorMapJetImg     :: ColorMapImg
colorMapWinterImg  :: ColorMapImg
colorMapRainbowImg :: ColorMapImg
colorMapOceanImg   :: ColorMapImg
colorMapSummerImg  :: ColorMapImg
colorMapSpringImg  :: ColorMapImg
colorMapCoolImg    :: ColorMapImg
colorMapHsvImg     :: ColorMapImg
colorMapPinkImg    :: ColorMapImg
colorMapHotImg     :: ColorMapImg
colorMapParulaImg  :: ColorMapImg

colorMapAutumImg   = mkColorMapImg ColorMapAutumn
colorMapBoneImg    = mkColorMapImg ColorMapBone
colorMapJetImg     = mkColorMapImg ColorMapJet
colorMapWinterImg  = mkColorMapImg ColorMapWinter
colorMapRainbowImg = mkColorMapImg ColorMapRainbow
colorMapOceanImg   = mkColorMapImg ColorMapOcean
colorMapSummerImg  = mkColorMapImg ColorMapSummer
colorMapSpringImg  = mkColorMapImg ColorMapSpring
colorMapCoolImg    = mkColorMapImg ColorMapCool
colorMapHsvImg     = mkColorMapImg ColorMapHsv
colorMapPinkImg    = mkColorMapImg ColorMapPink
colorMapHotImg     = mkColorMapImg ColorMapHot
colorMapParulaImg  = mkColorMapImg ColorMapParula

OpenCV Sphinx doc