next up previous 231
Next: Modifying images
Up: ACCESSING IMAGE DATA
Previous: Accessing an existing image

Creating a new image

This second example (taken from the program flat.f in the example directory - see §[*]), shows how to create a new image and then write values to it:
*  Create a new image.
      CALL IMG_NEW( 'OUT', 416, 578, IP, ISTAT )              [1]

*  Fill the array with the value 1.
      CALL DOFILL( %VAL( IP ), 416, 578, ISTAT )              [2]

*  Free the image.
      CALL IMG_FREE( 'OUT', ISTAT )                           [3]
      END

      SUBROUTINE DOFILL( IMAGE, NX, NY, ISTAT )
      INCLUDE 'SAE_PAR'
      REAL IMAGE( NX, NY )
      IF ( ISTAT .NE. SAI__OK ) RETURN

*  Loop over all the elements of the image setting them to 1.0.
      DO 1 J = 1, NY
         DO 2 I = 1, NX
            IMAGE( I, J ) = 1.0
 2       CONTINUE
 1    CONTINUE
      END
The following notes refer to the numbered statements:
1.
The call to IMG_NEW creates the new image dataset (usually prompting you for a name). The image size in this example is 416  x  578 pixels.

2.
The newly created image is passed to the subroutine DOFILL where all its elements are set to the value 1.0.

3.
Calling IMG_FREE ensures that the output image is correctly freed (avoiding possible loss of the data you have written).



next up previous 231
Next: Modifying images
Up: ACCESSING IMAGE DATA
Previous: Accessing an existing image

IMG Simple Image Data Access
Starlink User Note 160
P.W. Draper
R.F. Warren-Smith
3 March 2003
E-mail:P.W.Draper@durham.ac.uk

Copyright © 2000-2003 Council for the Central Laboratory of the Research Councils