Description
Haskell bindings for FlatCV image processing library.
Description
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.
README.md
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 stretchingrgbaToGrayscale- Convert to single-channel grayscalesingleToMultichannel- Convert grayscale to RGBA
Filtering
gaussianBlur- Apply Gaussian blur
Thresholding
otsuThreshold- Otsu's automatic thresholdingbwSmart- Smart black & white conversionapplyGlobalThreshold- Apply fixed threshold
Edge Detection
sobelEdgeDetection- Sobel edge detectionfoerstnerCorner- Foerstner corner detection
Morphological Operations
binaryDilationDisk- Binary dilationbinaryErosionDisk- Binary erosionbinaryClosingDisk- Binary closingbinaryOpeningDisk- Binary opening
Geometric Transforms
flipX,flipY- Flip horizontally/verticallytranspose,transverse- Transpose operationsrotate90CW,rotate180,rotate270CW- Rotationsresize- Resize with bilinear interpolation
Cropping & Trimming
crop- Crop rectangular regiontrim- Auto-trim borderstrimThreshold- Trim with threshold tolerance
Perspective Transform
calculatePerspectiveTransform- Calculate transform matrixapplyMatrix3x3- Apply 3x3 transformationdetectCorners- Detect document corners
Document Extraction
extractDocument- Extract with fixed output sizeextractDocumentAuto- Extract with automatic sizing
Drawing
drawCircle- Draw circle outlinedrawDisk- Draw filled circleaddBorder- Add border around image
Analysis
generateHistogram- Generate histogram visualization
Segmentation
watershedSegmentation- Watershed segmentation
Utility
getExifOrientation- Read JPEG EXIF orientationparseHexColor- Parse hex color stringconvertToBinary- Convert to binary with custom colors.