Image Action Set
Example 13.7 Comparing Images
Comparing Images
This section contains PROC CAS code.
Note: Input data must be in a CAS table that is accessible in your CAS session. This table has a two-level name; the first level is your CAS engine libref and the second level is the table name. You refer to this table in the CAS procedure by specifying only the second level. For more information about two-level names, see Chapter 3: Shared Concepts in SAS Visual Data Mining and Machine Learning 8.3: Procedures Guide. For more information about PROC CAS and programming in CASL, see Getting Started with CASL, SAS Cloud Analytic Services: CAS Procedure Programming Guide and Reference, and SAS Viya: System Programming Guide.
The following statements use the compareImages action to load images from the SourceImages and ReferenceImages directories, compare each image in the SourceImages directory with each image in the ReferenceImages directory, and output the similarity indices and filenames for each image pair. These statements assume that your CAS engine libref is named mycas, but you can substitute any appropriately defined CAS engine libref.
proc cas;
loadactionset "image";
image.loadImages / path="SourceImages"
casout={name="source", replication=0, replace=true};
image.loadImages / path="ReferenceImages"
casout={name="reference", replication=0, replace=true};
image.compareImages / sourceImages={table="source"}
referenceImages={table="reference"}
casOut={name="mycas.comparisons", replication=0, replace=true}
pairAll=TRUE;
run;
data mycomp; set mycas.comparisons; run;
proc print data=mycomp; run;
quit;
If each of the SourceImages and ReferenceImages directories contains three images named 1.bmp, 2.bmp, and 3.bmp, the output would look like Output 13.7.1.
Output 13.7.1: compareImages Output
| Obs | _channel1_ | _channel2_ | _channel3_ | _channel4_ | _source_id_ | _reference_id_ |
|---|---|---|---|---|---|---|
| 1 | 0.92434 | 0.98846 | 0.97123 | 1 | 3.bmp | 3.bmp |
| 2 | 0.00000 | 0.00000 | 0.00000 | 0 | 3.bmp | 1.bmp |
| 3 | 0.00000 | 0.00000 | 0.00000 | 0 | 3.bmp | 2.bmp |
| 4 | 0.99179 | 0.99794 | 0.99652 | 1 | 1.bmp | 1.bmp |
| 5 | 0.00000 | 0.00000 | 0.00000 | 0 | 1.bmp | 3.bmp |
| 6 | 0.27950 | 0.28518 | 0.28413 | 1 | 1.bmp | 2.bmp |
| 7 | 0.99159 | 0.99797 | 0.99669 | 1 | 2.bmp | 2.bmp |
| 8 | 0.27909 | 0.28517 | 0.28425 | 1 | 2.bmp | 1.bmp |
| 9 | 0.00000 | 0.00000 | 0.00000 | 0 | 2.bmp | 3.bmp |
Comparing Images
This example is not available for the Lua programming language.
Comparing Images
This example is not available for the Python programming language.
Comparing Images
This example is not available for the R programming language.