Spaces:
Sleeping
Sleeping
A newer version of the Gradio SDK is available: 6.15.2
metadata
title: Cell Image Visualization Tool
emoji: 🔬
colorFrom: blue
colorTo: green
sdk: gradio
sdk_version: 5.49.1
app_file: app.py
pinned: false
Cell Image Visualization Tool
This Gradio application allows you to visualize data points from spectroscopy measurements on microscopic cell images. It provides interactive controls to adjust image processing parameters for optimal cell boundary detection and coordinate mapping.
Features
- Upload Files: Upload a cell image (BMP format) and corresponding data file (TXT format)
- Interactive Parameter Adjustment: Fine-tune image processing parameters in real-time
- Cell Boundary Detection: Automatic detection of cell boundaries using adaptive thresholding and morphological operations
- Data Point Visualization: Visualize data points as inside (blue) or outside (orange) the detected cell boundary
- Coordinate Transformation: Adjustable pixels-per-micrometer conversion factor for accurate spatial mapping
- Diagnostic Output: View detailed information about the processing steps and results
How to Use
Upload Files:
- Upload your cell image (BMP format) using the "Upload Cell Image" button
- Upload your data file (TXT format with columns: x_um, y_um, z_um/wavelength, count) using the "Upload Data File" button
Adjust Parameters:
- Pixels per Micrometer: Adjust the conversion factor between micrometers and pixels (default: 21.3)
- Invert Y-axis: Toggle to invert the y-axis for coordinate mapping (default: enabled)
- Crop Size: Set the size of the region to process (default: 1000 pixels)
- Adaptive Threshold Parameters: Adjust block size and C value for adaptive thresholding
- Morphological Operations: Adjust kernel sizes for closing and opening operations
- Component Filtering: Set area thresholds for connected component analysis
- Contour Filtering: Set area and circularity thresholds for contour selection
Process and Visualize:
- Click the "Process and Visualize" button to generate the visualization
- View the result image with detected cell boundary and plotted data points
- Check the diagnostics output for detailed information about the processing
Visualization Legend
- Green Ellipse: Fitted ellipse to detected cell boundary
- Blue Contour: Detected cell boundary
- Blue Points: Data points inside the cell
- Orange Points: Data points outside the cell
- Green Cross: Start point (first row in TXT file)
- Red Cross: End point (last row in TXT file)
- White Scale Bar: 10 µm reference scale
Technical Details
The application uses the following image processing pipeline:
- Image Preprocessing: Gaussian blur to reduce noise
- Adaptive Thresholding: Local thresholding to handle varying illumination
- Morphological Operations: Closing to fill holes, opening to remove noise
- Connected Component Analysis: Identify and select the main cell component
- Contour Detection: Find and filter contours based on area and circularity
- Ellipse Fitting: Fit an ellipse to the detected cell boundary
- Coordinate Transformation: Map data points from micrometers to pixel coordinates
- Point Classification: Determine if each data point is inside or outside the cell
Requirements
- Python 3.11+
- gradio
- opencv-python
- pandas
- numpy
- Pillow
License
This application is provided as-is for research and educational purposes.