PROCESSMEDIMAGES Procedure
Getting Started: PROCESSMEDIMAGES Procedure
(View the complete code for this example.)
The example in this section shows how to use the PROCESSMEDIMAGES procedure to crop the input image to a desired size. 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.
The following PROC LOADIMAGES statement loads the image from the specified path into the mylib.input_image data table, which is specified in the OUTPUT statement. The specified path must be relative to the caslib that is associated with the "mylib" libref.
proc loadimages libref=mylib path='path/to/sample.tif';
output out=mylib.input_image addvars=(width height channelcount channeltype);
run;
Figure 1 shows that the mylib.input_image table contains a gray-scale image, which is indicated by a channel count of one.
Figure 1: The mylib.input_image Data Table
| Obs | _width_ | _height_ | _channelCount_ | _channelType_ | _image_ | _size_ | _path_ | _type_ | _id_ |
|---|---|---|---|---|---|---|---|---|---|
| 1 | 5 | 5 | 1 | 32F | ... | 278 | path/to/sample.tif | tif | 1 |
Then the following statements use PROC PROCESSMEDIMAGES to convert the input image to a biomedical format image by using the CONVERT option. You use the CROP statement to crop the image to a size of pixels by specifying the IMAGESIZE= option.
proc processmedimages data=mylib.input_image convert;
crop imagesize=(2,3);
output out=mylib.imported convert;
run;
The following PROC PRINT statement displays the contents of the mylib.imported data table that PROC PROCESSMEDIMAGES generates:
proc print data=mylib.imported;
run;
Figure 2 shows the mylib.imported data table that contains the imported image in biomedical format.
Figure 2: The mylib.imported Data Table
| Obs | _image_ | _size_ | _bioMedId_ | _bioMedDimension_ | _sliceIndex_ | _path_ |
|---|---|---|---|---|---|---|
| 1 | ... | 74 | 1 | 2 | 0 | path/to/sample.tif |
Note: You must use the CONVERT option in the OUTPUT statement to convert any image in biomedical format to image format in order for PROC DISPLAYIMAGES to display your image.