The flattenImages action converts an image table (containing binary image data) into a wide format table where each pixel represents a column. This is particularly useful for preparing image data for analytical models that require flat vector inputs. The action supports resizing images (height and width), changing the number of channels (e.g., converting to grayscale), grouping channels, and transposing image data during the flattening process.
| Parameter | Description |
|---|---|
| casOut | Specifies the settings for the output table, including the table name and caslib. |
| table | Specifies the input table that contains the image data to be flattened. |
| width | Specifies the target width of the output images. The default is 32. |
| height | Specifies the target height of the output images. The default is 32. |
| numberOfChannels | Specifies the number of channels for the output images. Values can be 'COLOR_IMAGE', 'GRAY_SCALE_IMAGE', or an integer. |
| groupChannels | When set to True, groups the channels of the images together (e.g., all blue pixels, then all green, then all red) in the output. |
| transpose | When set to True, transposes the images before writing them to the output table. |
| copyVars | Specifies a list of variables to copy from the input table to the output table. |
| image | Specifies the name of the column in the input table that contains the image binaries. Default is '_image_'. |
Loads sample images into a CAS table to be used as input for the flattenImages action.
| 1 | |
| 2 | PROC CAS; |
| 3 | image.loadImages / path="lib/images", caslib="CASUSER", casOut={name="source_images", replace=true}; |
| 4 | |
| 5 | RUN; |
| 6 |
Flattens the input images into a wide table using default settings (resizing to 32x32 pixels).
| 1 | |
| 2 | PROC CAS; |
| 3 | image.flattenImages / TABLE={name="source_images"} casOut={name="flat_basic", replace=true}; |
| 4 | |
| 5 | RUN; |
| 6 |
Flattens images with specific resizing to 64x64, converts them to grayscale, groups channels, and copies the label variable.
| 1 | |
| 2 | PROC CAS; |
| 3 | image.flattenImages / TABLE={name="source_images"} casOut={name="flat_advanced", replace=true} width=64 height=64 numberOfChannels="GRAY_SCALE_IMAGE" groupChannels=true copyVars={"_label_"}; |
| 4 | |
| 5 | RUN; |
| 6 |