This program is designed to analyze Scanning Electron Microscope (SEM) images, specifically images of superconducting quantum devices. It uses the Segment Anything library from Meta to identify and segment objects in the image.
extract_all_features.py
extract_select_features.py
- Installation
- Work In Progress
- Contributing
- License
`extract_all_features.py`
- Takes an SEM image as input and generates masks for all objects in the image.
- Displays each mask with a bounding box and the dimensions of the bounding box in nanometers.
- Saves each masked image in a directory structure:
results/name of input image/mask#_date created
. - Extracts the scale from the image and converts it to nanometers, regardless of the original unit.
The program works in several steps:
-
Input SEM Image: The user provides an SEM image as input. Here is an example of an input image:
-
Extract Scale: The program crops the bottom 80 pixels of the image, which contains the scale. It then uses OCR to extract the number and unit of the scale. Here is an example of the extracted scale:
-
Generate Masks: The program uses the Segment Anything library to generate masks for all objects in the image. It then sorts the masks by area and displays each mask with a bounding box. The dimensions of the bounding box are calculated in nanometers based on the extracted scale.
Here are examples of the masks generated for the main features in the image:
-
Save Images: The program saves each masked image in the
results/name of input image/
directory. The images are named according to the mask number and the date created.
- Run the program.
- When prompted, enter the path to the SEM image you want to analyze.
- The program will generate masks for all objects in the image and save the masked images in the
results/name of input image/
directory.
`extract_select_features.py`
- Takes an SEM image as input and generates masks for selected features in the image.
- Allows user to select points on the image to generate masks for specific features.
- Displays each mask with a bounding box and the dimensions of the bounding box in nanometers.
- Saves each masked image in a directory structure:
results/name of input image/mask#_date created
. - Extracts the scale from the image and converts it to nanometers, regardless of the original unit.
The program works in several steps:
- Load the 'Segment Anything' model: The program loads the model from Meta's Segment Anything library.
- Input SEM Image: The user provides an SEM image as input.
- Extract Scale: The program extracts the scale bar length from the image.
- Select Points: The user selects points on the image.
- Generate Masks: The program generates masks to extract the feature.
- Save Images: The program saves the masked image.
- Run the program.
- When prompted, enter the path to the SEM image you want to analyze.
- Enter the pixel scale (default is 370).
- Enter the number of inputs.
- The program will generate masks for the selected features in the image and save the masked images in the
results/name of input image/
directory.
- Install Python 3.7 or later.
- Download the checkpoint file from Meta and store them in the
weights
subdirectory and update the corresponding line in the main file
# Load the model
sam = sam_model_registry["vit_h"](checkpoint="weights/<checkpoint_file_name>")
- Clone this repository to your local machine.
- Install the required Python libraries. You can do this by running
pip install -r requirements.txt
in your terminal.
- Dynamic pixel scale extractor
- Batch Mode Processor with GUI (user clicks on all features of all images)
- Feature size statistical analysis (emission file, histograms, tables)
- Feature recognition in
extract_all_features.py
and statistical analysis - Negative mask click implementation
Contributions are welcome. Please open an issue to discuss your ideas or submit a pull request with your changes.
This project is licensed under the MIT License. See the LICENSE
file for details.