A Python-based GUI application for medical image mask correction and annotation. This tool allows users to load original images and their corresponding masks, and provides intuitive editing capabilities to refine mask boundaries for better accuracy in medical image analysis.
A professional, intuitive GUI application designed for medical image segmentation mask refinement and annotation workflows.
MedMaskEditor bridges the gap between automated segmentation algorithms and clinical precision requirements. Whether you're a researcher refining AI-generated masks, a clinician annotating medical images, or a data scientist preparing training datasets, this tool provides the precision and efficiency you need.
In medical image analysis, accurate segmentation masks are crucial for diagnosis, treatment planning, and research. However, automated segmentation often requires manual refinement to meet clinical standards. MedMaskEditor was specifically designed to make this process:
- Efficient: Navigate through hundreds of images with keyboard shortcuts and batch processing
- Precise: Pixel-perfect editing with adjustable brush sizes and real-time visual feedback
- User-friendly: Intuitive interface that doesn't require technical expertise
- Reliable: Handles large datasets with robust file management and auto-save functionality
🖼️ Triple-Panel Visualization: Simultaneous view of original image, editable mask, and overlay preview
🎨 Professional Editing Tools: Variable brush sizes, add/erase modes, and one-click mask reset
⚡ Real-time Feedback: Instant visual updates with colored overlays and contour highlighting
📁 Smart File Management: Automatic image-mask pairing with support for various formats
🌐 Unicode Support: Full compatibility with international file paths and names
🔄 Workflow Optimization: Auto-save, batch navigation, and progress tracking
- Dual Image Display: Side-by-side view of original images and masks
- Interactive Mask Editing: Draw and erase mask regions with adjustable brush sizes
- Overlay Visualization: Real-time overlay of masks on original images with adjustable transparency
- Batch Processing: Navigate through multiple images and masks efficiently
- Auto-save Functionality: Automatic saving of modifications during editing
- Jump Navigation: Quick access to any image in the dataset
- File Format Support: Supports common image formats (JPG, PNG, BMP, TIFF)
- Chinese Path Support: Handles file paths with Chinese characters
- Real-time Logging: System log display for operation tracking
The application features a three-panel layout:
- Left Panel: Original medical image
- Center Panel: Editable mask (black/white)
- Right Panel: Overlay visualization with colored mask and contours
- Right Sidebar: System logs and operation feedback
- Python 3.6+
- Required packages:
tkinter (usually included with Python) opencv-python pillow numpy
- Clone or download this repository
- Install required dependencies:
pip install opencv-python pillow numpy
- Run the application:
python correct_mask_gui.py
- Load Images: Click "选择图像文件夹" (Select Image Folder) to load original images
- Load Masks: Click "选择Mask文件夹" (Select Mask Folder) to load corresponding masks
- Navigate: Use "上一张"/"下一张" (Previous/Next) buttons or jump directly to specific images
- Edit Masks:
- Select brush size using the slider
- Choose "添加" (Add) or "擦除" (Erase) mode
- Draw directly on the center mask panel
- Save: Click "保存修改" (Save Changes) or enable "自动保存" (Auto-save)
- Transparency Control: Adjust overlay transparency to better visualize mask boundaries
- Mask Reset: Clear current mask with "重置Mask" (Reset Mask) button
- Jump Navigation: Enter image number in the jump field for quick access
- Real-time Preview: Overlay panel shows immediate feedback with colored masks and green contours
The application expects the following structure:
Project/
├── images/ # Original medical images
│ ├── image1.jpg
│ ├── image2.png
│ └── ...
└── masks/ # Corresponding mask images
├── image1.png
├── image2.png
└── ...
Note: Image and mask files should have matching names (excluding extensions).
To create a standalone executable file:
-
Install PyInstaller:
pip install pyinstaller
-
Build the executable:
pyinstaller --onefile --windowed --name=MaskCorrector correct_mask_gui.py
-
The executable will be created in the
dist/folder
- Safe Image Reading: Handles Chinese file paths using numpy buffer reading
- Real-time Mask Editing: Coordinate transformation for accurate pixel-level editing
- Memory Efficient: Only loads current image/mask pair
- Cross-platform: Works on Windows, macOS, and Linux
- Input: JPG, JPEG, PNG, BMP, TIFF
- Output: PNG (recommended for masks)
Contributions are welcome! Please feel free to submit issues, feature requests, or pull requests.
This project is open source. Please check the license file for details.
This tool is particularly useful for:
- Medical image annotation and correction
- Computer vision dataset preparation
- Manual refinement of automated segmentation results
- Quality control in medical imaging workflows
- Research in medical image analysis
For technical support or feature requests, please create an issue in the repository.
Note: This tool is designed for research and educational purposes. For clinical applications, please ensure proper validation and compliance with relevant medical standards.