The Colony Image Processing project is designed to address the challenge of automating the analysis of colonies on microscopy images. The solution emphasizes precision, consistency, and scalability, making it an excellent tool for research labs, diagnostic facilities, and educational purposes.
This project processes a dataset of 26 colony images by performing image segmentation to isolate colonies. It ensures the outputs meet specific deliverables:
- Original Images remain unaltered.
- Segmented Images highlight individual colonies.
- Combined Images provide a side-by-side comparison of the original and segmented images.
- Unique Verification Codes confirm processing integrity for each image.
The key requirements:
- Preserve the original image resolution across all outputs.
- Automate the pipeline to deliver 78 images (26 originals, 26 segmented, 26 combined) within a strict 4-day deadline.
The project is powered by a Python-based script that employs efficient image processing techniques, ensuring high-quality outputs. Here's a summary of its features:
- Colony Segmentation: Uses adaptive thresholding (Otsu's method) combined with morphological operations to isolate colonies from the background.
- Side-by-Side Comparison: Generates a visual comparison between the original and processed images.
- Metadata Logging: Creates JSON files with paths, unique verification codes, and processing details for each image.
- Automation: Processes all images in batch mode, ensuring timely delivery.
- Traceability: Maintains a detailed log of actions for reproducibility and debugging.
- Python Libraries: OpenCV, NumPy, scikit-image.
- Image Processing Techniques: Grayscale conversion, Gaussian blurring, adaptive thresholding, and noise reduction.
The algorithm:
- Converts images to grayscale for uniformity.
- Reduces noise with Gaussian blur.
- Applies Otsu's thresholding to segment colonies.
- Refines results using morphological operations to remove small artifacts.
Three types of images are generated:
- Original Images: Saved without modifications.
- Segmented Images: Binary masks highlighting colonies.
- Combined Images: Side-by-side visual comparisons.
Each processed image generates:
- A JSON metadata file with file paths and a unique verification code.
- An entry in a log file documenting processing details.
Each code combines:
- A timestamp for temporal traceability.
- A hash of the segmented image for uniqueness.
The project code is modular and structured for scalability:
- Initialization: Sets up input/output directories and creates subdirectories for organized outputs.
- Segmentation Logic: Encapsulated in the
segment_colonies()
function, which applies the image processing pipeline. - Automation: The
process_all_images()
method processes all images in the input directory. - Error Handling: Logs errors for unsupported formats or corrupted files, ensuring smooth execution.
The output directory contains:
output/
├── combined/ # Side-by-side images
├── original/ # Original images
├── segmented/ # Segmented images
├── metadata.json # Metadata for each image
└── processing_log.txt # Logs processing actions
A JSON file (image1_metadata.json
) contains:
{
"original_path": "./output/original/image1_original.png",
"segmented_path": "./output/segmented/image1_segmented.png",
"combined_path": "./output/combined/image1_combined.png",
"verification_code": "PROC_20241117213045_1a2b3c4d"
}
- Python 3.7+
- Libraries: Install dependencies via:
pip install -r requirements.txt
Run the script using:
python main.py --input_dir <path_to_input_images> --output_dir <path_to_output_dir>
python main.py --input_dir ./images/input --output_dir ./images/output
- Advanced Segmentation: Replace
segment_colonies()
with custom algorithms for more complex datasets. - Parallel Processing: Incorporate multiprocessing to handle larger datasets efficiently.
- Visualization Enhancements: Add additional outputs like 3D plots or quantitative analysis.
Issue | Solution |
---|---|
Image not found error | Check if --input_dir path exists and contains supported image files. |
Empty output directory | Review processing_log.txt for error details. |
Unsupported file format | Ensure files are .jpg , .png , .tif , or .tiff . |
The Colony Image Processing project is a robust and flexible tool tailored for image segmentation tasks in scientific and research applications. By automating tedious workflows and ensuring high-quality outputs, it empowers users to focus on insights rather than manual image analysis. For further inquiries or contributions, visit the GitHub repository.