Image utilities.
Function | read |
Reads the image from the given path as a numpy array. |
Function | reencode |
Re-encodes the image to the format specified by the given output path. |
Function | reencode |
Re-encodes the images in the sample collection to the given format. |
Function | transform |
Transforms the image according to the provided parameters. |
Function | transform |
Transforms the images in the sample collection according to the provided parameters. |
Function | write |
Writes image to file. |
Variable | logger |
Undocumented |
Function | _do |
Undocumented |
Function | _get |
Undocumented |
Function | _parse |
Undocumented |
Function | _parse |
Undocumented |
Function | _transform |
Undocumented |
Function | _transform |
Undocumented |
Function | _transform |
Undocumented |
Function | _transform |
Undocumented |
Reads the image from the given path as a numpy array.
Color images are returned as RGB arrays.
Parameters | |
path | Undocumented |
includeFalse | whether to include the alpha channel of the image, if present, in the returned array |
flag:None | an optional OpenCV image format flag to use. If provided, this flag takes precedence over include_alpha |
path | the filepath or URL of the image |
Returns | |
a uint8 numpy array containing the image |
Re-encodes the image to the format specified by the given output path.
Parameters | |
input | the path to the input image |
output | the path to write the output image |
Re-encodes the images in the sample collection to the given format.
If no output_dir is specified and delete_originals is False, then if a transformation would result in overwriting an existing file with the same filename, the original file is renamed to <name>-original.<ext>.
Note
This method will not update the metadata field of the collection after transforming. You can repopulate the metadata field if needed by calling:
sample_collection.compute_metadata(overwrite=True)
Parameters | |
sample | a
fiftyone.core.collections.SampleCollection |
ext:".png" | the image format to use (e.g., ".png" or ".jpg") |
forceTrue | whether to re-encode images whose extension already matches ext |
media | the input field containing the image paths to transform |
outputNone | an optional field in which to store the paths to the transformed images. By default, media_field is updated in-place |
outputNone | an optional output directory in which to write the transformed images. If none is provided, the images are updated in-place |
relNone | an optional relative directory to strip from each input filepath to generate a unique identifier that is joined with output_dir to generate an output path for each image. This argument allows for populating nested subdirectories in output_dir that match the shape of the input paths |
updateTrue | whether to store the output paths on the sample collection |
deleteFalse | whether to delete the original images after re-encoding |
numNone | a suggested number of worker processes to use |
skipFalse | whether to gracefully continue without raising an error if an image cannot be re-encoded |
progress:None | whether to render a progress bar (True/False), use the default value fiftyone.config.show_progress_bars (None), or a progress callback function to invoke instead |
Transforms the image according to the provided parameters.
Parameters | |
input | the path to the input image |
output | the path to write the output image |
size:None | an optional (width, height) for the image. One dimension can be -1, in which case the aspect ratio is preserved |
minNone | an optional minimum (width, height) for the image. A dimension can be -1 if no constraint should be applied. The image is resized (aspect-preserving) if necessary to meet this constraint |
maxNone | an optional maximum (width, height) for the image. A dimension can be -1 if no constraint should be applied. The image is resized (aspect-preserving) if necessary to meet this constraint |
interpolation:None | an optional interpolation argument for cv2.resize() |
Transforms the images in the sample collection according to the provided parameters.
If no output_dir is specified and delete_originals is False, then if a transformation would result in overwriting an existing file with the same filename, the original file is renamed to <name>-original.<ext>.
Note
This method will not update the metadata field of the collection after transforming. You can repopulate the metadata field if needed by calling:
sample_collection.compute_metadata(overwrite=True)
Parameters | |
sample | a
fiftyone.core.collections.SampleCollection |
size:None | an optional (width, height) for each image. One dimension can be -1, in which case the aspect ratio is preserved |
minNone | an optional minimum (width, height) for each image. A dimension can be -1 if no constraint should be applied. The images are resized (aspect-preserving) if necessary to meet this constraint |
maxNone | an optional maximum (width, height) for each image. A dimension can be -1 if no constraint should be applied. The images are resized (aspect-preserving) if necessary to meet this constraint |
interpolation:None | an optional interpolation argument for cv2.resize() |
ext:None | an optional image format to re-encode the source images into (e.g., ".png" or ".jpg") |
forceFalse | whether to re-encode images whose parameters already match the specified values |
media | the input field containing the image paths to transform |
outputNone | an optional field in which to store the paths to the transformed images. By default, media_field is updated in-place |
outputNone | an optional output directory in which to write the transformed images. If none is provided, the images are updated in-place |
relNone | an optional relative directory to strip from each input filepath to generate a unique identifier that is joined with output_dir to generate an output path for each image. This argument allows for populating nested subdirectories in output_dir that match the shape of the input paths |
updateTrue | whether to store the output paths on the sample collection |
deleteFalse | whether to delete the original images if any transformation was applied |
numNone | a suggested number of worker processes to use |
skipFalse | whether to gracefully continue without raising an error if an image cannot be transformed |
progress:None | whether to render a progress bar (True/False), use the default value fiftyone.config.show_progress_bars (None), or a progress callback function to invoke instead |
Undocumented
Undocumented
Undocumented
Undocumented