| Crates.io | scirs2-vision |
| lib.rs | scirs2-vision |
| version | 0.1.0-beta.2 |
| created_at | 2025-04-12 19:55:19.804983+00 |
| updated_at | 2025-09-20 09:04:09.324829+00 |
| description | Computer vision module for SciRS2 (scirs2-vision) |
| homepage | |
| repository | https://github.com/cool-japan/scirs |
| max_upload_size | |
| id | 1631208 |
| size | 3,187,077 |
Computer vision module for SciRS2, providing comprehensive functionality for image processing, feature detection, segmentation, and color transformations.
✅ PRODUCTION READY - Final alpha release with complete functionality:
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.
use scirs2_vision::{
sobel_edges, harris_corners, image_to_array, array_to_image
};
use scirs2_vision::{prewitt_edges, laplacian_edges, laplacian_of_gaussian};
use scirs2_vision::feature::{canny_simple, fast_corners, shi_tomasi_corners};
use scirs2_vision::gaussian_blur;
// Load an image and convert to array
let img = image::open("input.jpg")?;
let img_array = image_to_array(&img)?;
// Preprocess with Gaussian blur
let blurred = gaussian_blur(&img, 1.0)?;
// Detect edges using Sobel (available in public API)
let sobel = sobel_edges(&img, 0.1)?;
// Detect edges using Canny
let canny_result = canny_simple(&img_array, 1.0)?;
// Detect edges using Prewitt (available in public API)
let prewitt_result = prewitt_edges(&img, 0.1)?;
// Detect edges using Laplacian (available in public API)
let laplacian_result = laplacian_edges(&img, 0.05, true)?;
// Detect edges using Laplacian of Gaussian (available in public API)
let log_result = laplacian_of_gaussian(&img, 1.0, 0.05)?;
// Detect corners using Harris (available in public API)
let corners = harris_corners(&img, 3, 0.04, 0.01)?;
// Detect corners using FAST
let fast_corners = fast_corners(&img_array, 9, 0.05)?;
// Detect corners using Shi-Tomasi
let shi_tomasi = shi_tomasi_corners(&img_array, 100, 0.01, 10.0)?;
use scirs2_vision::{rgb_to_hsv, rgb_to_lab, split_channels, image_to_array};
// Load an image and convert to array
let img = image::open("input.jpg")?;
let img_array = image_to_array(&img)?;
// Convert to HSV
let hsv = rgb_to_hsv(&img_array)?;
// Convert to LAB
let lab = rgb_to_lab(&img_array)?;
// Split into channels
let (r_channel, g_channel, b_channel) = split_channels(&img_array)?;
use scirs2_vision::{
threshold_binary, otsu_threshold, adaptive_threshold, connected_components,
image_to_array, AdaptiveMethod,
};
// Load an image and convert to array
let img = image::open("input.jpg")?;
let img_array = image_to_array(&img)?;
// Apply Otsu's thresholding
let (binary, threshold) = otsu_threshold(&img_array)?;
// Apply adaptive thresholding
let adaptive = adaptive_threshold(&img_array, 11, 0.02, AdaptiveMethod::Gaussian)?;
// Perform connected component labeling
let (labeled, num_components) = connected_components(&binary)?;
use scirs2_vision::{
erode, dilate, opening, closing, morphological_gradient,
image_to_array, StructuringElement,
};
// Load an image and convert to array
let img = image::open("input.jpg")?;
let img_array = image_to_array(&img)?;
// Define a structuring element
let se = StructuringElement::Ellipse(5, 5);
// Apply opening (erosion followed by dilation)
let opened = opening(&img_array, se)?;
// Calculate morphological gradient
let gradient = morphological_gradient(&img_array, se)?;
use scirs2_vision::{log_blob_detect, image_to_array, LogBlobConfig};
use scirs2_vision::feature::{
dog_detect, DogConfig,
mser_detect, MserConfig,
hough_circles, HoughCircleConfig
};
// Load an image and convert to array
let img = image::open("input.jpg")?;
let img_array = image_to_array(&img)?;
// Detect blobs using Difference of Gaussians
let dog_config = DogConfig::default();
let dog_blobs = dog_detect(&img_array, dog_config)?;
// Detect blobs using Laplacian of Gaussian (available in public API)
let log_config = LogBlobConfig::default();
let log_blobs = log_blob_detect(&img_array, log_config)?;
// Detect stable regions using MSER
let mser_config = MserConfig::default();
let mser_regions = mser_detect(&img_array, mser_config)?;
// Detect circles using Hough Transform
let hough_config = HoughCircleConfig::default();
let circles = hough_circles(&img_array, hough_config)?;
Add scirs2-vision to your dependencies in Cargo.toml:
[dependencies]
scirs2-vision = "0.1.0-beta.2"
To enable optimizations through the core module, add feature flags:
[dependencies]
scirs2-vision = { version = "0.1.0-beta.2", features = ["parallel"] }
For detailed documentation, examples, and API reference, please refer to the API documentation and the examples directory.
The module includes a comprehensive test suite to ensure functionality works as expected:
# Run all tests (217 tests passing)
cargo test
# Run tests with output to see detailed results
cargo test -- --nocapture
# Run specific test module
cargo test preprocessing
# Run specific test
cargo test test_grayscale_conversion
scirs2-core: Core functionality for SciRS2scirs2-ndimage: N-dimensional image processingndarray: N-dimensional array manipulationimage: Basic image processing in Rustnum-traits and num-complex: Numerical type traitsThis project is dual-licensed under:
You can choose to use either license. See the LICENSE file for details.
This 0.1.0-beta.2 release represents a mature, production-ready computer vision library suitable for:
All implemented algorithms have been validated against reference implementations and tested with:
The public API is considered stable for the alpha release series, meaning:
Post-alpha development will focus on:
Contributions are welcome! Please see the project's CONTRIBUTING.md file for guidelines.
For the post-alpha roadmap, we're particularly interested in: