Image¶
giant.utilities.stereophotoclinometry
:
- class giant.utilities.stereophotoclinometry.Image(file_name=None, n_cols=None, n_rows=None, maximum_illumination=None, integer_size=None, endianess=None, data=None)[source]¶
This class is used to read and write from SPC Image files (.DAT).
The Image files contain the 2D image data for SPC processing.
When creating an instance of this class you can enter the
file_name
argument and the data will automatically be read from that file. Alternatively you can specify individual components of the object through key word arguments. If you provide both key word arguments and a file name then the key word arguments you specified will overwrite anything read from the file.Because the image files are a minimal format, you must specify the number of columns, number of rows, and maximum illumination value in addition to the file name. These can be determined by reading the corresponding summary file for the image (
Summary
). As an alternative to the maximum illumination you can specify the integer size and endianess arguments if known.- Parameters:
file_name (Path | str | None) – The path to a summary file to read data from
n_cols (int | None) – The number of columns in the image
n_rows (int | None) – The number of rows in the image
maximum_illumination (Real | None) – The maximum illumination value that is possible in the image. This is used to attempt to discern the endianess of the file, so it typically should be set to either 255 for 8 bit or 65535 for 16 bit.
integer_size (int | None) –
endianess (str | None) –
data (Sequence | ndarray | None) –
- file_name: Path | str | None¶
The path to the image file that this object was populated from.
This also will be the file that changes are written to if
write()
is called with no arguments.Typically this is named according to IMAGEFILES/IMAGENAME.DAT where IMAGENAME is replaced with the SPC name of the image. This can be set to None, a str, or a
Path
.
- n_cols: int | None¶
The number of columns in the image.
This must be specified before the image file is read. It can be determined by the
Summary.n_cols
attribute from the corresponding summary file.
- n_rows: int | None¶
The number of rows in the image.
This must be specified before the image file is read. It can be determined by the
Summary.n_rows
attribute from the corresponding summary file.
- maximum_illumination¶
The maximum possible illumination for an image.
This is used to try to discern the endianess of the file if it is not known and the file has 16 bit integers, but it is not foolproof. If you know the endianess of the file you should specify that instead.
- integer_size: int | None¶
The number of bytes for each integer in the file.
This is discerned from the total number of bytes in the file vs the total number of pixels computed from
n_rows
andn_cols
. A value of 1 indicates an 8 bit integer while a value of 2 indicates a 16 bit integer. If you know this already then you can specify it to increase reading speed slightly.This is required to be not
None
before a call to write is made.
- endianess: str | None¶
The endianess of the data in the file if it is stored in 16 bit integers.
This may be able to be inferred if it is not known and the
maximum_illumination
value is specified; however, this is not foolproof and may not work. Therefore, if you know the endianess for 16 bit files you should specify it.This should be either ‘>’ for big-endian or ‘<’ for little-endian’
This must be specified before a call to
write()
if the integer size is 16 bit. This doesn’t matter if the integer size is 8 bit.
- data: Sequence | ndarray | None¶
The actual image data as a 2D numpy array
Summary of Methods
This method reads data from a SPC Image file (normally |
|
This function writes the file contained in the Image object to a dat file |