next up previous contents
Next: Pointer Images Up: Imrects Previous: Image Types   Contents

Image Indexing

In order to index element j on row i we must write

    im->array.ushort_v[i][j]

Provided that the image location is within the region of interest covered by the imrect.

An existing contiguous block of data may be wrapped within an Imrect data structure via a call to

Imrect *im_wrap_contig(void *mem_ptr, int height, int width,
                       Imregion * region, Vartype vtype)

The following shorthand macros provide a more simple syntax for image indexing

    IM_CHAR(im, i, j)
    IM_ UCHAR(im, i, j)
    IM_SHORT(im, i, j)
    IM_USHORT(im, i, j)
    IM_INT(im, i, j)
    IM_ UINT(im, i, j)
    IM_FLOAT(im, i, j)
    IM_DOUBLE(im, i, j)
    IM_COMPLEX(im, i, j)
    IM_PTR(im, i, j)
    IM_VRAM0(_im,_i,_j)
    IM_VRAM1(_im,_i,_j)
    IM_VRAM2(_im,_i,_j)
    IM_VRAM3(_im,_i,_j)

Even so it is still necessary to check the type and region covered by the imrect prior to application of the macro. Generic functions for accessing and manipulating imrects of all kinds that explicitly check the region can be found in the list of functions at the end of this chapter.

Note that indexing the scheme is with respect to the coordinates of the underlying image (as defined by the height and width fields of the imrect) rather than relative to the lower corner (numerically rather than physically) of the region of interest of the current imrect. Furthermore, it is possible that image indices can have negative values.


next up previous contents
Next: Pointer Images Up: Imrects Previous: Image Types   Contents
root 2017-11-24