EXTRACTOBJECTS Procedure
Example 7.5 Crop and Save Object Detections in Multiple Columns
(View the complete code for this example.)
This example shows how to use the EXTRACTOBJECTS procedure to crop object detections and save them in multiple-column format. For more information, see the section Cropping Detected Objects.
The code in this example assumes that the mylib.yolo_annotations table is loaded in advance. It has one image, and that image (see Figure 2) has two object detections that are annotated in YOLO format (see Output 7.3.1).
The following statements crop the two object detections in the input image by using the annotations that are provided in YOLO format. The resulting table, mylib.objects, contains cropped images that are saved in multiple columns when you specify the FORMAT= option in the OUTPUT statement.
proc extractobjects data=mylib.yolo_annotations
coordinateformat=yolo maxobjects=2 method=crop;
output out=mylib.objects format=multiplecolumns;
run;
The following PROC PRINT statement displays the mylib.objects table, which is generated by the previous statements:
proc print data=mylib.objects;
run;
Output 7.5.1 shows that the mylib.objects table has image binaries of two cropped images that are saved in the variables _image0_ and _image1_.
Output 7.5.1: The mylib.objects Table
| Obs | _path_ | _image0_ | _image1_ |
|---|---|---|---|
| 1 | /path/to/birds.png | ... | ... |
You can use the following PROC DISPLAYIMAGES statement to display the first cropped object:
proc displayimages data=mylib.objects;
image _image0_;
run;
Output 7.5.2 shows the ODS output of PROC DISPLAYIMAGES.
Output 7.5.2: Image of First Cropped Object

You can use the following PROC DISPLAYIMAGES statement again to display the second cropped object:
proc displayimages data=mylib.objects;
image _image1_;
run;
Output 7.5.3 shows the ODS output of PROC DISPLAYIMAGES.
Output 7.5.3: Image of Second Cropped Object
