Spaces:
Sleeping
A newer version of the Gradio SDK is available:
6.9.0
title: Microscopy CV Toolkit
emoji: 🔬
colorFrom: green
colorTo: blue
sdk: gradio
sdk_version: 5.23.0
app_file: app.py
pinned: true
license: apache-2.0
tags:
- microscopy
- computer-vision
- image-quality
- opencv
Microscopy CV Toolkit
I needed a quick way to check if my microscopy images are in focus before feeding them into ML pipelines. Couldn't find anything lightweight that just does the basics without pulling in a 2GB model, so I built this. Pure OpenCV, no models, runs instant.
What it does
Four tools in one space:
Focus Quality - Runs Tenengrad, Laplacian variance, normalized variance, and Vollath F4 on your image. Generates a heatmap overlay so you can see which regions are sharp and which are mush. I use this to filter out bad acquisitions before they waste training time.
Illumination Analysis - Checks brightness distribution, detects clipping (blown highlights / crushed blacks), measures dynamic range, and flags vignetting. Splits the image into a 3x3 zone grid so you can see if your Kohler illumination is actually aligned or if you've been lying to yourself.
Microscopy Type Detection - Tries to figure out if you're looking at brightfield, darkfield, phase contrast, fluorescence, or polarized light. It's histogram-based, not magic. Works surprisingly well for standard preparations but don't expect miracles on weird edge cases.
Image Enhancement - CLAHE, unsharp mask, non-local means denoising, and auto white balance. Side-by-side before/after so you can see what each one does. Good for quick previews before you commit to a processing pipeline. The CLAHE configration is tuned for typical microscopy contrast ranges but you can adjust the parameters.
How it works
Everything is classical CV. Focus metrics are computed on grayscale using gradient operators and statistical measures. Illumination analysis uses histogram statistics and zone-based sampling. Type detection looks at histogram shape, mean intensity, contrast ratios, and edge density to classify teh imaging modality. Enhancement is standard OpenCV stuff.
No GPU needed. No model downloads. Should run in under a second for most images.
Running locally
pip install -r requirements.txt
python app.py
License
Apache 2.0. Do whatever you want with it.