A versatile toolkit to analyze roots within petri dishes.
Project description
cv2_group: Python toolkit for analyzing plant roots
| Category | Badges |
|---|---|
| Testing | |
| Package | |
| License | |
| Docker |
About
cv2_group is a Python package that provides robust computer vision tools specifically designed for automated organ segmentation and landmark detection in images of plants grown in Petri dishes.
Modern plant science increasingly relies on high-throughput image analysis, but manually processing these images is often time-consuming and prone to inconsistency. This package addresses that challenge by offering a scalable and reliable solution. Built upon advanced computer vision models, cv2_group transforms raw plant images into valuable data, enabling researchers to efficiently track plant development, analyze organ morphology, and identify key anatomical landmarks.
At its core, cv2_group leverages a U-Net model to accurately segment plant organs and detect specific landmarks. The package is developed with a focus on modularity, ensuring it's easy to maintain, test, and extend for future research needs. It provides a powerful foundation for automated plant phenotyping, moving beyond manual analysis to deliver consistent and precise results at scale.
This system is designed to streamline data extraction from plant imagery, offering a crucial tool for accelerating research in plant biology, agriculture, and related fields.
Table of Contents
- cv2_group: Python toolkit for analyzing plant roots
Main Features
The cv2_group package allows you to analyze roots within a petri dish, here are some of the most useful features:
- Cropping images based on the petri dish: Precisely isolates the area of interest in the image.
- Automated organ segmentation: Accurately identifies and delineates specific plant organs within the images using advanced U-Net models.
- Landmark detection: Pinpoints key anatomical points on the plants for detailed analysis.
- Support for image uploads: Facilitates easy integration of your image datasets for processing.
- Modular and maintainable design: Built as a fully modular Python package for easy maintenance, testing, and future extensions.
- API and CLI access: Provides flexible interfaces for users to interact with the system and perform analyses.
- Automated model performance tracking and continuous training support: Ensures the system remains accurate and up-to-date by monitoring prediction accuracy and triggering retraining with new data.
Where to get it
The latest release of cv2_group is available on PyPI:
pip install cv2_group
Dependencies
The cv2_group package relies on the following core dependencies to provide its functionality:
numpy==1.23.5opencv-python==4.10.0.84scikit-image==0.22.0patchify==0.2.3tensorflow==2.10.0matplotlib==3.8.4pillow==10.3.0scikit-learn(version compatible with^1.6.1)fastapi==0.110.0uvicorn==0.29.0typer==0.9.0click==8.1.3
These dependencies will be installed automatically when you install the cv2_group package using pip or Poetry
Installing the package
You can use cv2_group in your Python environment either by installing it directly from PyPI or by using Poetry for dependency management.
Option 1: Install via PyPI
If you're using pip, simply run:
pip install cv2_group
This will automatically install all required dependencies listed in the package.
Option 2: Install via Poetry
If you have cloned the cv2_group repository (e.g., from GitHub) and want to set up its development environment or run it directly from the source code, navigate to the root directory of the repository (which contains the pyproject.toml file).
Then, simply run:
poetry install
This command will read the pyproject.toml file, create a dedicated virtual environment (if it doesn't exist), and install all necessary project dependencies within it.
poetry shell
Using the package
The cv2_group package offers various functions organized into modules to help you analyze plant roots in petri dish images.
Command Line Interface (CLI)
For a quick start, you can run the main prediction pipeline directly from your terminal:
poetry run root-predictor path/to/image.jpg
This command will process the specified image, applying the underlying models to generate predictions.
Python API
You can also integrate cv2_group functions directly into your Python scripts for more customized workflows. Below is an overview of the key functions organized by their respective subpackages:
Load image
cv2_group.data.data_ingestion.load_image(image_path: str) -> ndarray
Loads an image from image_path and converts it to a grayscale NumPy array. Useful as the first step for processing.
from cv2_group.data.data_ingestion import load_image
image = load_image("path/to/your/image.jpg")
Create patches
cv2_group.data.data_processing.create_patches(image: ndarray, patch_size: int) -> Tuple[ndarray, int, int, ndarray]
Divides a grayscale image into non-overlapping square RGB patches of patch_size. Essential for processing large images with deep learning models.
from cv2_group.data.data_processing import create_patches
patches, num_rows, num_cols, padded_rgb_image = create_patches(image, patch_size=256)
Load trained model
load_trained_model(model_path)
Loads a pre-trained U-Net or other compatible model from a specified file path.
from cv2_group.models import load_trained_model
model = load_trained_model("path/to/your/model.h5")
Analyize primary root
cv2_group.features.feature_extraction.analyze_primary_root(root_instances: List[ndarray | None], original_roi_indices: List[int]) -> List[Dict[str, Any]]
Analyzes primary root characteristics from a list of individual root mask instances. Provides biological insights from segmented roots.
from cv2_group.features.feature_extraction import analyze_primary_root
analysis_results = analyze_primary_root(list_of_root_masks, corresponding_indices)
Map identified root labels
cv2_group.features.feature_extraction.find_labels_in_rois(label_ids: ndarray, totalLabels: int, stats: ndarray, centroids: ndarray, rois: List[Tuple[int, int, int, int]]) -> Tuple[Dict[str, int | None], List[int]]
Maps identified root labels (individual components) to predefined Regions of Interest (ROIs). Useful for spatially organizing analysis results.
from cv2_group.features.feature_extraction import find_labels_in_rois
mapped_labels, unassigned = find_labels_in_rois(labels, total, stats, centroids, rois_list)
Visualize overlay
cv2_group.utils.visualization.display_overlay(cropped_image: ndarray, predicted_mask: ndarray, alpha: float = 0.5, show: bool = False, return_png_bytes: bool = True) -> bytes | None
Creates a visual overlay of the predicted binary root mask on the original image, useful for quick visual validation or for web display.
from cv2_group.utils.visualization import display_overlay
overlay_bytes = display_overlay(original_image, predicted_mask, return_png_bytes=True)
License
Documentation
The official documentation is hosted on Github Pages
Background
Work on cv2_group started at Breda University of Applied Sciences BUas in 2025 and has been under development since then.
Contact
For questions, feedback, or contributions, feel free to reach out to the team:
- Martin Simons – Frontend Specialist – 235439@buas.nl
- Yorbe Heeren – DMP Specialist – 232922@buas.nl
- Arnout Opfergelt – Deployment Specialist – 230858@buas.nl
- Victor Oorthuis – GitHub / Unit Testing / Documentation Specialist – 233189@buas.nl
- Teun van der Wolf – Azure ML Specialist – 235874@buas.nl
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cv2_group-1.0.0.tar.gz.
File metadata
- Download URL: cv2_group-1.0.0.tar.gz
- Upload date:
- Size: 139.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.3 CPython/3.10.13 Windows/10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0b1e24bcf391130450414ccd8632b5eac951fc7774112cfcb9efc9c8d17aa168
|
|
| MD5 |
b4d87b2c293e149805b224fe5f50e3b0
|
|
| BLAKE2b-256 |
b786d7fbc5c94974e8f13ffabf43e254c5ed222eb411982dc971372df67813f0
|
File details
Details for the file cv2_group-1.0.0-py3-none-any.whl.
File metadata
- Download URL: cv2_group-1.0.0-py3-none-any.whl
- Upload date:
- Size: 157.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.3 CPython/3.10.13 Windows/10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d64ab966b5f426563124d229d612be6ef7f8e2f0873457d28c2f9bd559591f82
|
|
| MD5 |
f247709f33ad3c5cac1155504eef65d1
|
|
| BLAKE2b-256 |
b00f0ec5de255255e3947cbb4350b648280d8e534ce699495fba37dd9b6504da
|