Image Action Set

Change Bit Depth and Scale Pixel Values Using the processImages action

This section contains PROC CAS code.

Note: Input data must be accessible in your CAS session, either as a CAS table or as a transient-scope table. A CAS 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 2, Shared Concepts (SAS Visual Data Mining and Machine Learning: Procedures). A transient-scope table is called directly from the action and exists in memory for the duration of the action. For more information about accessing data, see SAS Viya: System Programming Guide. For more information about PROC CAS and programming in CASL, see SAS Cloud Analytic Services: CASL Programmer’s Guide and SAS Cloud Analytic Services: CASL Reference.

The following SAS code uses the RESCALE value of the functionType parameter to convert the bit depth of the image and linearly scale each pixel of the image. The type parameter specifies the bit depth. The alpha parameter is a multiplicative factor for each pixel. The beta parameter is an additive constant for each pixel. The output images are then written to the imgsOut output table. This code assumes that the imgs table is loaded in advance.

proc cas;
 image.processImages /
  casOut={name="imgsOut", replace=True}
  imagefunctions={{
   functionOptions={
	   functionType="RESCALE",
	   type="TO_8U",
	   alpha=2,
	   beta=-128
	   }
   }}
  table={name="imgs"};
quit;

Output 17.60.1 compares the original and processed images.

Output 17.60.1: Image Comparison

sas_q_md rescale_processed
Original Image Processed Image


Change Bit Depth and Scale Pixel Values Using the processImages action

This example is not available for the Lua programming language.

Change Bit Depth and Scale Pixel Values Using the processImages action

This section contains Python code. For more information about coding in Python, see Getting Started with SAS Viya for Python and SAS Viya: System Programming Guide.

The following Python code uses the RESCALE value of the functionType parameter to convert the bit depth of the image and linearly scale each pixel of the image. The type parameter specifies the bit depth. The alpha parameter is a multiplicative factor for each pixel. The beta parameter is an additive constant for each pixel. The output images are then written to the imgsOut output table. This code assumes that the imgs table is loaded in advance.

s.image.processImages(
    casOut={'name':'imgsOut', 'replace':True},
    imageFunctions=[
        {'options':{
            'functionType':'RESCALE',
            'type':'TO_8U',
                        'alpha':2,
                        'beta':-128
        }}
    ],
    table=imgs
)

Output 17.60.2 compares the original and processed images.

Output 17.60.2: Image Comparison

sas_q_md rescale_processed
Original Image Processed Image


Change Bit Depth and Scale Pixel Values Using the processImages action

This example is not available for the R programming language.

Last updated: November 04, 2020