Reflection High-Energy Electron Diffraction
This module contains functions for Reflection High-Energy Electron Diffraction (RHEED) data. These functions primarily convert two file types: RHEED .img image files and RHEED .imm video files. The rheedconverter function also supports Crysalis Pro Single Crystal diffraction .img images. The two main functions in this module are rheedconverter and rheed_video_converter. Other functions serve as helpers for these two.
Both main functions perform the same core task: converting 16bpp images or videos to 8bpp. This can be helpful when working with RHEED data, as 16bpp files are not easily viewable on most standard systems. Some functions in this module rely on specific headers found in the original file formats. If your data does not include these headers, the functions may not work correctly.
RHEED Image Converter
rheedconverter takes a RHEED .img file as input, extracts all image data, and converts it into a .png file. Here is an example of how the function rheedconverter can be used:
from project_chameleon.rheedconverter import rheedconverter
rheedconverter('new_image.img', 'new_image.png')
In this example, ‘new_image.img’ is the raw RHEED image file containing the data. ‘new_image.png’ is the name of the output file that will contain the converted image data. No metadata is collected or displayed by this function.
RHEED Video Converter
rheed_video_converter takes a RHEED .imm file as input, processes each video frame, and saves the adjusted video as a .avi or .mp4 file. Here is an example of how the function rheed_video_converter can be used:
from project_chameleon.rheed_video_converter import rheed_video_converter
rheed_video_converter('new_image.imm', 'new_video.avi', keep_images='0')
In this example, ‘new_image.imm’ is the RHEED video file. ‘new_video.avi’ is the output video file after conversion. The output format can be either .avi (lossless) or .mp4 (lossy), depending on the desired compression.
The keep_images parameter is optional. If set to ‘1’, a folder will be created containing each video frame as a separate image file. If set to ‘0’, no frame images will be saved. This parameter defaults to ‘0’.
Below is more information on the main functions, as well as their helper functions:
- rheed_helpers.get_image_dimensions(input_file)
get_image_dimensions()is a function that extracts file dimensions from a RHEED image. This function has been designed based on RHEED images given, and may not work correctly if your files are of a different type.- Args:
input_fileshould be a RHEED image. This does not have to be a file.- Returns:
height (int), width (int), header_size(int)
- Exception:
None
- rheed_helpers.rheed_video_frame_parser(input_file, height, width, header_bytes)
rheed_video_frame_parseris a function that takes a file and images dimensions and converts them to a 2D array.- Args:
input_fileshould be a RHEED image file.heightshould be an integer of the image height.widthshould be an integer of the image width.header_bytesshould be an integer of the size of the header.- Returns:
laue, a 2D array containing the image data for the given RHEED image.
- Exception:
None
- rheed_helpers.rheed_video_image_parser(input_file, output_folder='rheed_video_temp')
rheed_video_image_parseris a function that gets the dimension of a given RHEED image, converters it to a .png image, and saves it to a folder. This function utilizes the functionality of theget_image_dimensionsfunction.- Args:
input_fileshould be a RHEED image file.ouptut_foldershould be a string or path leading to a folder. This argument is optional.- Returns:
This function does not return anything. A folder is created and all images are saved there.
- Exception:
None