SciRS2 Vision
Computer vision module for SciRS2, providing comprehensive functionality for image processing, feature detection, segmentation, and color transformations.
⚠️ SciRS2 POLICY Migration: This module is currently being updated to follow the SciRS2 POLICY - migration from direct rand:: usage to scirs2-core abstractions is in progress.
Production Status (0.1.0)
✅ PRODUCTION READY - stable release with SciRS2 POLICY implementation:
- 217 unit tests passing with zero warnings
- Comprehensive API covering all major computer vision operations
- Working examples demonstrating real-world usage
- Performance optimized with parallel processing support
- SciPy-compatible design for familiar scientific computing workflows
- Ecosystem Consistency: Migrating to scirs2-core abstractions for consistent APIs
Overview
The scirs2-vision module provides a complete computer vision library for scientific computing applications. This production-ready module includes implementations of state-of-the-art algorithms for feature detection, image processing, segmentation, and geometric transformations.
Comprehensive Feature Set
🎯 Feature Detection and Description
- Edge Detection: Sobel, Canny, Prewitt, Laplacian operators with sub-pixel accuracy
- Corner Detection: Harris corners, Shi-Tomasi (Good Features to Track), FAST corners
- Blob Detection: DoG (Difference of Gaussians), LoG (Laplacian of Gaussian), MSER regions
- Feature Descriptors: ORB descriptors, BRIEF descriptors, HOG (Histogram of Oriented Gradients)
- Feature Matching: RANSAC-based robust matching, homography estimation
- Geometric Detection: Hough Circle Transform, Hough Line Transform
- Advanced Features: Sub-pixel corner refinement, non-maximum suppression
🖼️ Image Enhancement and Preprocessing
- Noise Reduction: Non-local means denoising, bilateral filtering, guided filtering
- Enhancement: Histogram equalization, CLAHE, gamma correction (auto/adaptive)
- Filtering: Gaussian blur, median filtering, unsharp masking
- Contrast Enhancement: Brightness/contrast normalization, Retinex algorithms
- Quality Analysis: Image quality assessment metrics
🎨 Color and Texture Analysis
- Color Space Conversions: RGB ↔ HSV, RGB ↔ LAB with proper gamma correction
- Color Processing: Channel splitting/merging, weighted grayscale conversion
- Color Quantization: K-means, median cut, octree quantization algorithms
- Texture Analysis: Gray-level co-occurrence matrix (GLCM), Local binary patterns (LBP)
- Advanced Texture: Gabor filters, Tamura texture features
✂️ Image Segmentation
- Thresholding: Binary, Otsu's automatic, adaptive (mean/Gaussian) methods
- Region Segmentation: SLIC superpixels, watershed algorithm, region growing
- Advanced Segmentation: Mean shift clustering, connected component analysis
- Interactive Segmentation: Multi-level thresholding, texture-based segmentation
🔄 Geometric Transformations
- Affine Transformations: Translation, rotation, scaling, shearing with multiple interpolation methods
- Perspective Transformations: Homography-based warping with robust estimation
- Non-rigid Transformations: Thin-plate spline deformation, elastic transformations
- Interpolation: Bilinear, bicubic, Lanczos, edge-preserving interpolation methods
- Image Registration: Feature-based and intensity-based alignment
🧮 Morphological Operations
- Basic Operations: Erosion, dilation with customizable structuring elements
- Advanced Operations: Opening, closing, morphological gradient
- Specialized Operations: Top-hat, black-hat transforms for feature enhancement
Examples
Feature Detection
use ;
use ;
use ;
use gaussian_blur;
// Load an image and convert to array
let img = open?;
let img_array = image_to_array?;
// Preprocess with Gaussian blur
let blurred = gaussian_blur?;
// Detect edges using Sobel (available in public API)
let sobel = sobel_edges?;
// Detect edges using Canny
let canny_result = canny_simple?;
// Detect edges using Prewitt (available in public API)
let prewitt_result = prewitt_edges?;
// Detect edges using Laplacian (available in public API)
let laplacian_result = laplacian_edges?;
// Detect edges using Laplacian of Gaussian (available in public API)
let log_result = laplacian_of_gaussian?;
// Detect corners using Harris (available in public API)
let corners = harris_corners?;
// Detect corners using FAST
let fast_corners = fast_corners?;
// Detect corners using Shi-Tomasi
let shi_tomasi = shi_tomasi_corners?;
Color Transformations
use ;
// Load an image and convert to array
let img = open?;
let img_array = image_to_array?;
// Convert to HSV
let hsv = rgb_to_hsv?;
// Convert to LAB
let lab = rgb_to_lab?;
// Split into channels
let = split_channels?;
Image Segmentation
use ;
// Load an image and convert to array
let img = open?;
let img_array = image_to_array?;
// Apply Otsu's thresholding
let = otsu_threshold?;
// Apply adaptive thresholding
let adaptive = adaptive_threshold?;
// Perform connected component labeling
let = connected_components?;
Morphological Operations
use ;
// Load an image and convert to array
let img = open?;
let img_array = image_to_array?;
// Define a structuring element
let se = Ellipse;
// Apply opening (erosion followed by dilation)
let opened = opening?;
// Calculate morphological gradient
let gradient = morphological_gradient?;
Blob and Region Detection
use ;
use ;
// Load an image and convert to array
let img = open?;
let img_array = image_to_array?;
// Detect blobs using Difference of Gaussians
let dog_config = default;
let dog_blobs = dog_detect?;
// Detect blobs using Laplacian of Gaussian (available in public API)
let log_config = default;
let log_blobs = log_blob_detect?;
// Detect stable regions using MSER
let mser_config = default;
let mser_regions = mser_detect?;
// Detect circles using Hough Transform
let hough_config = default;
let circles = hough_circles?;
Installation
Add scirs2-vision to your dependencies in Cargo.toml:
[]
= "0.1.2"
To enable optimizations through the core module, add feature flags:
[]
= { = "0.1.2", = ["parallel"] }
Documentation
For detailed documentation, examples, and API reference, please refer to the API documentation and the examples directory.
Performance and Production Characteristics
🚀 High Performance
- Parallel Processing: Multi-threaded implementations using Rayon for CPU-intensive operations
- Memory Efficient: Optimized algorithms that minimize memory allocation and copying
- SIMD Ready: Foundation for SIMD acceleration in performance-critical paths
- Benchmarked: Algorithms tested against reference implementations for accuracy and speed
🔧 Production Features
- Robust Error Handling: Comprehensive error types with detailed diagnostic information
- Parameter Validation: Input validation for all algorithms with clear error messages
- Thread Safety: All algorithms are thread-safe and can be used in concurrent applications
- SciPy Compatibility: API design follows SciPy conventions for familiar usage patterns
📊 Quality Assurance
- 217 Unit Tests: Comprehensive test coverage for all implemented functionality
- Zero Warnings: Clean code following Rust best practices and Clippy recommendations
- Working Examples: All documentation examples are tested and verified to work
- Continuous Integration: Automated testing ensures reliability across different environments
Testing
The module includes a comprehensive test suite to ensure functionality works as expected:
# Run all tests (217 tests passing)
# Run tests with output to see detailed results
# Run specific test module
# Run specific test
Dependencies
scirs2-core: Core functionality for SciRS2scirs2-ndimage: N-dimensional image processingndarray: N-dimensional array manipulationimage: Basic image processing in Rustnum-traitsandnum-complex: Numerical type traits
License
This project is dual-licensed under:
You can choose to use either license. See the LICENSE file for details.
Production Readiness
This 0.1.0 release represents a mature, production-ready computer vision library suitable for:
🏭 Production Applications
- Scientific Computing: Research applications requiring reliable computer vision algorithms
- Image Processing Pipelines: Batch processing of scientific imagery with parallel processing
- Computer Vision Research: Foundation for building advanced vision applications
- Educational Use: Teaching computer vision concepts with real, working implementations
🔬 Validated Algorithms
All implemented algorithms have been validated against reference implementations and tested with:
- Numerical Accuracy: Results compared against established libraries like OpenCV and SciPy
- Edge Cases: Comprehensive testing of boundary conditions and error scenarios
- Performance: Benchmarked for reasonable performance characteristics
- Memory Safety: Rust's guarantees ensure memory safety without runtime overhead
🎯 API Stability
The public API is considered stable for Stable Release (stable), meaning:
- Production Ready: API is stable with minimal changes expected before 1.0
- Consistent Interface: Function signatures and behavior will remain consistent
- Backward Compatibility: New features will be added without breaking existing code
- Clear Documentation: All public functions are documented with examples
- Zero Warnings: Full clippy compliance and code quality assurance
- Semantic Versioning: Version numbers follow semantic versioning principles
Future Development
Post-RC development will focus on:
- Performance Optimization: SIMD acceleration and GPU support
- Advanced Algorithms: Deep learning integration and advanced computer vision techniques
- Domain-Specific Features: Medical imaging, remote sensing, and specialized applications
- Extended Format Support: Additional image formats and metadata handling
Contributing
Contributions are welcome! Please see the project's CONTRIBUTING.md file for guidelines.
For the post-alpha roadmap, we're particularly interested in:
- Performance optimizations and benchmarking
- Additional computer vision algorithms
- Domain-specific applications and use cases
- Integration with machine learning frameworks