Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def open(filename, frame='unspecified'):
""" Opens a segmentation image """
data = Image.load_data(filename)
return SegmentationImage(data, frame)
----------
filename : :obj:`str`
The file to load the data from. Must be one of .png, .jpg,
.npy, or .npz.
frame : :obj:`str`
A string representing the frame of reference in which the new image
lies.
Returns
-------
:obj:`DepthImage`
The new depth image.
"""
file_root, file_ext = os.path.splitext(filename)
data = Image.load_data(filename)
if file_ext.lower() in COLOR_IMAGE_EXTS:
data = (data * (MAX_DEPTH / BINARY_IM_MAX_VAL)).astype(np.float32)
return DepthImage(data, frame)
Parameters
----------
filename : :obj:`str`
The file to load the data from. Must be one of .png, .jpg,
.npy, or .npz.
frame : :obj:`str`
A string representing the frame of reference in which the new image
lies.
Returns
-------
:obj:`IrImage`
The new IR image.
"""
data = Image.load_data(filename)
data = (data * (MAX_IR / BINARY_IM_MAX_VAL)).astype(np.uint16)
return IrImage(data, frame)
Parameters
----------
filename : :obj:`str`
The file to load the data from. Must be one of .png, .jpg,
.npy, or .npz.
frame : :obj:`str`
A string representing the frame of reference in which the new image
lies.
Returns
-------
:obj:`PointCloudImage`
The new PointCloudImage.
"""
data = Image.load_data(filename)
return PointCloudImage(data, frame)
Parameters
----------
filename : :obj:`str`
The file to load the data from. Must be one of .png, .jpg,
.npy, or .npz.
frame : :obj:`str`
A string representing the frame of reference in which the new image
lies.
Returns
-------
:obj:`NormalCloudImage`
The new NormalCloudImage.
"""
data = Image.load_data(filename)
return NormalCloudImage(data, frame)
Parameters
----------
filename : :obj:`str`
The file to load the data from. Must be one of .png, .jpg,
.npy, or .npz.
frame : :obj:`str`
A string representing the frame of reference in which the new image
lies.
Returns
-------
:obj:`ColorImage`
The new color image.
"""
data = Image.load_data(filename).astype(np.uint8)
return ColorImage(data, frame)
Parameters
----------
filename : :obj:`str`
The file to load the data from. Must be one of .png, .jpg,
.npy, or .npz.
frame : :obj:`str`
A string representing the frame of reference in which the new image
lies.
Returns
-------
:obj:`BinaryImage`
The new binary image.
"""
data = Image.load_data(filename)
if len(data.shape) > 2 and data.shape[2] > 1:
data = data[:, :, 0]
return BinaryImage(data, frame)
Parameters
----------
filename : :obj:`str`
The file to load the data from. Must be one of .png, .jpg,
.npy, or .npz.
frame : :obj:`str`
A string representing the frame of reference in which the new image
lies.
Returns
-------
:obj:`GrayscaleImage`
The new grayscale image.
"""
data = Image.load_data(filename)
return GrayscaleImage(data, frame)