A simple, LabelMe-like annotation tool for AI4med data preprocessing with an intuitive GUI interface. This tool allows users to easily annotate medical images by clicking to place 600×600 pixel rectangular regions.
- Simple GUI Interface: LabelMe-like interface that's easy to use
- Click-to-Annotate: Simply click on the image to place a 600×600 pixel rectangular annotation
- Automatic Window Sizing: Adapts to your screen resolution for optimal viewing
- Scroll Support: Automatically shows horizontal/vertical scrollbars for large images
- JSON Export: Saves annotations in LabelMe-compatible JSON format
- Image Support: Supports common image formats (PNG, JPG, JPEG, BMP, TIF, TIFF)
- Python 3.6 or higher
- PyQt5
# Install PyQt5
pip install pyqt5# Start the tool and select an image through the GUI
python main.py
# Or directly load an image
python main.py path/to/your/image.png- Open an Image: Click the "打开图片 (Open)" button to select an image file
- Annotate: Click anywhere on the image to place a 600×600 pixel rectangular annotation
- Save: Click "保存标签 (Save)" to export the annotation as a JSON file
The tool exports annotations in LabelMe-compatible JSON format:
{
"version": "5.8.3",
"flags": {},
"shapes": [
{
"label": "d",
"points": [[x1, y1], [x2, y2]],
"group_id": null,
"description": "",
"shape_type": "rectangle",
"flags": {},
"mask": null
}
],
"imagePath": "image_name.jpg",
"imageData": "base64_encoded_image_data",
"imageHeight": 1080,
"imageWidth": 1920
}- Automatic Resolution Adaptation: The window automatically adjusts to your screen size
- Scroll Support: Large images automatically get scrollbars for easy navigation
- Real-time Drawing: Annotations are drawn immediately when you click
- Boundary Clipping: Rectangles are automatically clipped to image boundaries
- Base64 Image Encoding: Images are embedded in the JSON for complete annotation files
labelPZY/
├── main.py # Main application file
├── .gitignore # Git ignore rules (only tracks main.py)
└── d/ # Output directory for JSON files
└── *.json # Generated annotation files
- PyQt5: For the GUI interface
- pathlib: For file path handling
- json: For JSON export
- base64: For image encoding
This tool was developed for AI4med data preprocessing workflows, providing a simple and efficient way to annotate medical images for machine learning training.
- Added "Open Image" button functionality
- Automatic resolution adaptation
- Horizontal/vertical scrollbar support for large images
- Improved button layout
This tool is designed for AI4med data preprocessing workflows.
Feel free to submit issues and enhancement requests for this medical image annotation tool.