visualinspection.detection.yolox.resizeLetterbox
R2026bSyntax
Description
Resize an image while preserving the aspect ratio using the
visualinspection.detection.yolox.resizeLetterbox function. This function is
useful when you preprocess input images for YOLOX object detection in ONNX Runtime. Resizing
an image while preserving the aspect ratio avoids distortion of objects in the image while
still matching the size of the image to the input size of the object detector. This process is
known as letterboxing.
Export a trained YOLOX object detector to an ONNX model file using the
exportONNXNetworkfunction.Preprocess test images for inference in ONNX Runtime using the
visualinspection.detection.yolox.resizeLetterboxfunction.Run the inference using the ONNX model externally or by simulating ONNX inference in MATLAB®.
Postprocess raw predictions from the ONNX inference using the
visualinspection.detection.yolox.postprocessfunction.
The detect
object function of the yoloxObjectDetector object performs the preprocessing and postprocessing
internally. If you do not need to run inference in ONNX Runtime, you can continue using the
detect function.
[
resizes the image resizedImage,resizeFactor] = visualinspection.detection.yolox.resizeLetterbox(I,targetSize)I to the target size targetSize
while applying constant value padding to preserve its aspect ratio. The function returns the
resized image resizedImage and the resize factor
resizeFactor. To accurately identify the locations of detected
objects, you must use the same resize factor during postprocessing to convert the raw
predictions to bounding boxes.
[___] = visualinspection.detection.yolox.resizeLetterbox(___,PadValue=
specifies the constant value of the padding in addition to the arguments from the previous
syntax.padValue)
Examples
Input Arguments
Output Arguments
Extended Capabilities
Version History
Introduced in R2026b
