flatcv: Haskell bindings for FlatCV image processing library

[ graphics, image, library ] [ Propose Tags ] [ Report a vulnerability ]

FlatCV is a lightweight, dependency-free image processing library written in C. This package provides Haskell bindings to the FlatCV library, enabling fast image operations like grayscale conversion, Gaussian blur, edge detection, perspective transforms, and more.

The library is particularly useful for document scanning and image preprocessing tasks.


[Skip to Readme]

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.3.0, 0.3.0.1
Change log changelog.md
Dependencies base (>=4.12 && <5), vector (>=0.12 && <0.14) [details]
License ISC
Copyright 2025 Adrian Sieber
Author Adrian Sieber
Maintainer mail@adriansieber.com
Uploaded by adrian at 2026-01-17T19:14:03Z
Category Graphics, Image
Home page https://github.com/ad-si/FlatCV
Bug tracker https://github.com/ad-si/FlatCV/issues
Source repo head: git clone https://github.com/ad-si/FlatCV.git
Distributions
Downloads 2 total (2 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for flatcv-0.3.0.1

[back to package description]

FlatCV Haskell Bindings

Haskell bindings for the FlatCV image processing library.

Usage

import FlatCV
import qualified Data.Vector.Storable as V

main :: IO ()
main = do
  -- Assuming you have RGBA image data as a Vector Word8
  let
    width = 640
    height = 480
    -- imageData :: V.Vector Word8

  -- Convert to grayscale
  grayData <- grayscale width height imageData

  -- Apply Gaussian blur
  blurredData <- gaussianBlur width height 2.0 imageData

  -- Detect edges
  edges <- sobelEdgeDetection width height 4 imageData

  -- Extract a document from a photo
  (outW, outH, docData) <- extractDocumentAuto width height imageData

Available Functions

Color Conversion

  • grayscale - Convert RGBA to grayscale (4-channel output)
  • grayscaleStretch - Grayscale with contrast stretching
  • rgbaToGrayscale - Convert to single-channel grayscale
  • singleToMultichannel - Convert grayscale to RGBA

Filtering

  • gaussianBlur - Apply Gaussian blur

Thresholding

  • otsuThreshold - Otsu's automatic thresholding
  • bwSmart - Smart black & white conversion
  • applyGlobalThreshold - Apply fixed threshold

Edge Detection

  • sobelEdgeDetection - Sobel edge detection
  • foerstnerCorner - Foerstner corner detection

Morphological Operations

  • binaryDilationDisk - Binary dilation
  • binaryErosionDisk - Binary erosion
  • binaryClosingDisk - Binary closing
  • binaryOpeningDisk - Binary opening

Geometric Transforms

  • flipX, flipY - Flip horizontally/vertically
  • transpose, transverse - Transpose operations
  • rotate90CW, rotate180, rotate270CW - Rotations
  • resize - Resize with bilinear interpolation

Cropping & Trimming

  • crop - Crop rectangular region
  • trim - Auto-trim borders
  • trimThreshold - Trim with threshold tolerance

Perspective Transform

  • calculatePerspectiveTransform - Calculate transform matrix
  • applyMatrix3x3 - Apply 3x3 transformation
  • detectCorners - Detect document corners

Document Extraction

  • extractDocument - Extract with fixed output size
  • extractDocumentAuto - Extract with automatic sizing

Drawing

  • drawCircle - Draw circle outline
  • drawDisk - Draw filled circle
  • addBorder - Add border around image

Analysis

  • generateHistogram - Generate histogram visualization

Segmentation

  • watershedSegmentation - Watershed segmentation

Utility

  • getExifOrientation - Read JPEG EXIF orientation
  • parseHexColor - Parse hex color string
  • convertToBinary - Convert to binary with custom colors