The compareImages action compares images from a source table with images from a reference table. It supports two comparison methods: Peak Signal-to-Noise Ratio (PSNR) and Structural Similarity Index (SSIM). The results, including the comparison values, are stored in an output table. This action is useful for tasks like quality control, change detection, or finding duplicate images.
| Parameter | Description |
|---|---|
| casOut | Specifies the output table to store the comparison results. This is a required parameter. |
| referenceImages | Specifies the input table containing the reference images for comparison. This is a required parameter. |
| sourceImages | Specifies the input table containing the source images to be compared. This is a required parameter. |
| copyVars | Specifies a list of variables to copy from the input tables to the output table. |
| maximum | Specifies the maximum comparison value to report in the output. Default is the largest possible machine double. |
| method | Specifies the comparison method. Can be 'PSNR' (Peak Signal-to-Noise Ratio) or 'SSIM' (Structural Similarity Index). Default is 'SSIM'. |
| minimum | Specifies the minimum comparison value to report in the output. Default is the negative of the largest possible machine double. |
| pairAll | If set to TRUE, compares every source image with every reference image. Default is FALSE. |
| pairOnPath | If set to TRUE, indicates that the pairing variables specified in `pairSourceOn` and `pairReferenceOn` are file paths. Default is TRUE. |
| pairReferenceOn | Specifies the variable in the reference table to use for pairing images. Default is '_path_'. |
| pairSourceOn | Specifies the variable in the source table to use for pairing images. Default is '_path_'. |
| separateChannels | If set to TRUE, the comparison is performed on each color channel separately. Default is TRUE. |
This example demonstrates how to load two sets of images (source and reference) from server paths into two distinct CAS tables, `source_images` and `reference_images`. These tables will then be used for comparison.
| 1 | PROC CAS; |
| 2 | image.loadImages / |
| 3 | path='path/to/source/images' |
| 4 | casOut={name='source_images', caslib='casuser', replace=true}; |
| 5 | image.loadImages / |
| 6 | path='path/to/reference/images' |
| 7 | casOut={name='reference_images', caslib='casuser', replace=true}; |
| 8 | RUN; |
This example compares images between `source_images` and `reference_images` tables using the default Structural Similarity Index (SSIM) method. Images are paired based on their file paths.
| 1 | PROC CAS; |
| 2 | image.compareImages / |
| 3 | sourceImages={TABLE={name='source_images', caslib='casuser'}} |
| 4 | referenceImages={TABLE={name='reference_images', caslib='casuser'}} |
| 5 | casOut={name='comparison_results', caslib='casuser', replace=true}; |
| 6 | RUN; |
This example uses the Peak Signal-to-Noise Ratio (PSNR) method to compare images. It only reports results where the PSNR is between 20 and 50. The comparison is done on the grayscale versions of the images (by setting `separateChannels` to FALSE), and an additional variable `_id_` is copied to the output table.
| 1 | PROC CAS; |
| 2 | image.compareImages / |
| 3 | sourceImages={TABLE={name='source_images', caslib='casuser'}} |
| 4 | referenceImages={TABLE={name='reference_images', caslib='casuser'}} |
| 5 | casOut={name='psnr_results', caslib='casuser', replace=true} |
| 6 | method='PSNR' |
| 7 | minimum=20 |
| 8 | maximum=50 |
| 9 | separateChannels=false |
| 10 | copyVars={'_id_'}; |
| 11 | RUN; |
This example demonstrates a many-to-many comparison by setting `pairAll` to TRUE. Every image in the `source_images` table is compared against every image in the `reference_images` table using the SSIM method.
| 1 | PROC CAS; |
| 2 | image.compareImages / |
| 3 | sourceImages={TABLE={name='source_images', caslib='casuser'}} |
| 4 | referenceImages={TABLE={name='reference_images', caslib='casuser'}} |
| 5 | casOut={name='all_pairs_comparison', caslib='casuser', replace=true} |
| 6 | pairAll=true; |
| 7 | RUN; |