ANNOTATEIMAGES Procedure
Getting Started: ANNOTATEIMAGES Procedure
(View the complete code for this example.)
The example in this section shows how to use PROC ANNOTATEIMAGES to overlay a biomedical image with its segmentation. This example assumes that the CAS engine libref "mylib" and the caslib that is associated with "mylib" have already been created. For more information, see the section Setting Up Your Environment for Working with Images in Chapter 1, Shared Concepts.
First, you can use the LOADIMAGES procedure to load a CT image of human lungs from the specified path into the mylib.source_image data table. The specified path must be relative to the caslib that is associated with the "mylib" libref.
proc loadimages libref=mylib path='path/to/image/lungCT.jpg';
output out=mylib.source_image;
run;
Figure 1 shows the image that has been loaded into the session, which displays a 2-D CT image of human lungs (Armato et al. 2015a, 2015b; Armato et al. 2016; Clark et al. 2013).
Figure 1: 2-D CT Image of Human Lungs

After the CT image is loaded, you can use PROC LOADIMAGES again to load a single-channel segmentation image into the mylib.segmentation_image data table:
proc loadimages libref=mylib path='path/to/image/segmentation_image.png';
output out=mylib.segmentation_image;
run;
Figure 2 shows the image that has been loaded into the session as a segmentation image.
Figure 2: Segmentation Image

Then, you merge the mylib.source_image and mylib.segmentation_image tables into one table named mylib.joined_table by using the following statements:
proc fedsql sessref=mysess;
create table joined_table as
select src._id_, src._image_ as source_image, seg._image_ as seg_image
from source_image as src, segmentation_image as seg
where src._id_ = seg._id_;
quit;
Note: These statements create a merged table by renaming the mylib.source_image image variable as source_image and the mylib.segmentation_image image variable as seg_image, and then they retain those renamed variables along with the _id_ variable.
The following PROC PRINT statements display the contents of the mylib.joined_table data table that is generated by the previous statements:
proc print data=mylib.joined_table;
run;
Figure 3 shows the output, which displays the image and metadata columns.
Figure 3: The mylib.joined_table Data Table
| Obs | _id_ | SOURCE_IMAGE | SEG_IMAGE |
|---|---|---|---|
| 1 | 1 | ... | ... |
Finally, you use PROC ANNOTATEIMAGES to overlay the source image with the segmentation image:
proc annotateimages data=mylib.joined_table;
image source_image;
segmentation seg_image / colorMap="jet" transparency=20 inputbackground=0;
output out=mylib.annotated_images;
run;
Note: The color map is specified to use the "jet" color map for annotation. A value of 20% is specified as the transparency. The background value for the input segmentation image is black, so the INPUTBACKGROUND= option is set to 0.
Figure 4 shows the output of the procedure.
Figure 4: Annotated Image
