Skip to main content

Unified interface for SEM image processing: metadata extraction, OCR-based pixel size estimation, and unit conversion

Project description

sem-meta

A unified Python package for SEM (Scanning Electron Microscopy) image processing, providing metadata extraction, OCR-based pixel size estimation, and unit conversion utilities.

Features

  • SEMMetaData: Extract and format metadata from SEM images
  • SEMOCR: OCR-based pixel size estimation from scale bars
  • ConvertPS: Unit conversion and error analysis for pixel size data
  • FullSEMKeys: Standardized metadata key list for SEM images

Installation

Install from PyPI:

pip install sem-meta

Quick Start

from sem_meta import SEMMeta, OCRPS, ConvertScale, FullSEMKeys

# Extract metadata from SEM images
metadata = SEMMeta.extract_metadata("path/to/sem/image.tif")

# Perform OCR on scale bars
pixel_size = OCRPS.extract_pixel_size("path/to/image/with/scalebar.tif")

# Convert units
converted_size = ConvertScale.convert_units(pixel_size, "μm", "nm")

# Access standardized SEM metadata keys
sem_keys = FullSEMKeys

Main Components

SEMMetaData

Extracts and processes metadata from SEM image files, particularly TIFF files with EXIF data.

SEMOCR

Uses OCR (Optical Character Recognition) to extract pixel size information from scale bars in SEM images. Includes noise filtering and error correction for common OCR mistakes.

ConvertPS

Handles unit conversion and normalization for pixel size measurements, supporting various scientific units commonly used in microscopy.

FullSEMKeys

Provides a standardized set of metadata keys for consistent SEM image annotation and data extraction.

Dependencies

  • numpy: Numerical computations
  • PIL (Pillow): Image processing
  • pymysql: SQL safety utilities
  • termcolor: Terminal output styling
  • matplotlib: Visualization
  • opencv-python: Advanced image preprocessing
  • pytesseract: OCR functionality

Requirements

  • Python 3.6+
  • Tesseract OCR engine (for OCR functionality)

Installing Tesseract

Ubuntu/Debian:

sudo apt install tesseract-ocr

macOS:

brew install tesseract

Windows: Download and install from: https://github.com/UB-Mannheim/tesseract/wiki

Usage Examples

Extracting SEM Metadata

from sem_meta import SEMMeta

# Initialize and extract metadata
sem_processor = SEMMeta
metadata = sem_processor.extract_metadata("sample.tif")
print(metadata)

OCR-based Scale Bar Reading

from sem_meta import OCRPS

# Extract pixel size from scale bar
ocr_processor = OCRPS
pixel_size = ocr_processor.extract_pixel_size("sem_image.tif")
print(f"Pixel size: {pixel_size}")

Unit Conversion

from sem_meta import ConvertScale

# Convert between units
converter = ConvertScale
result = converter.convert_units("0.5 μm", "nm")
print(f"Converted: {result}")

File Structure

sem-meta/
├── src/
│   └── sem_meta/
│       ├── __init__.py
│       ├── metadata_Module.py    # SEMMetaData class
│       ├── ocr_Module.py         # SEMOCR class
│       ├── convert_Module.py     # ConvertPS class
│       ├── SEMKEYS.py           # FullSEMKeys definitions
│       └── OCR_NOISE_DB.py      # OCR noise patterns database
├── README.md
├── LICENSE
└── pyproject.toml

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Authors

  • Ahmed Khalil - Initial work

Acknowledgments

  • Built for the SEM imaging community
  • Supports various SEM manufacturers' metadata formats
  • Includes extensive OCR noise pattern recognition

Support

If you encounter any problems or have questions, please open an issue on the GitHub repository.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sem_meta-0.1.1.tar.gz (38.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sem_meta-0.1.1-py3-none-any.whl (33.9 kB view details)

Uploaded Python 3

File details

Details for the file sem_meta-0.1.1.tar.gz.

File metadata

  • Download URL: sem_meta-0.1.1.tar.gz
  • Upload date:
  • Size: 38.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for sem_meta-0.1.1.tar.gz
Algorithm Hash digest
SHA256 fe4aa8a4485a6a18ec172fd16f5c44ba854e27936a64d046fbe25a904a0aa76b
MD5 f95df872fee7b9696a9a49ded66324bb
BLAKE2b-256 aa6b3294f6f5045d70a0181d52bcfcad4195775e87b91d56b4e941e8a6dd9fb2

See more details on using hashes here.

File details

Details for the file sem_meta-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: sem_meta-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 33.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for sem_meta-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6d6b8f1bd80457fd05ee170725f146e1b90bb9cf182fb32bdd93def6c07a4f0c
MD5 9318a49850bf8fa3f5c1df7c564950ff
BLAKE2b-256 aef515bbe4508eadb31b0e7e4ab9be7d2100214171ec2dac42f373f7efa801c0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page