Image-class             package:EBImage             R Documentation

_D_e_f_i_n_t_i_o_n _o_f _c_l_a_s_s '_I_m_a_g_e', _i_t_s _a_c_c_e_s_s_o_r _m_e_t_h_o_d_s

_D_e_s_c_r_i_p_t_i_o_n:

     The class 'Image' enables the storage and manipulation of image
     data for grayscale and true color (RGB) images in 'R'. The class
     is based on  (derived from) 'array' and inherits all its
     properties and methods, e.g. mathematical operations, subsetting,
     histograms etc. Image processing and analysis routines are defined
     as S4 methods for objects of the class 'Image'.

_C_l_a_s_s _D_e_f_i_n_i_t_i_o_n:

     The class is defined as follows:


     ## S4 class definition

     setClass( "Image",
       representation (
         colormode    = "integer", 
         filename     = "character",
         compression  = "character", 
         resolution   = "numeric",   
         features     = "list"
       ),
       contains = "array"
     )

     Additionally, two constants are defined and exported that can be
     used to specify or test image data type:


       Grayscale = as.integer(0)
       TrueColor = as.integer(1)


_C_r_e_a_t_i_n_g _o_b_j_e_c_t_s:

     Objects can be created using 'new("Image")' supplying slot data as
     necessary. Additionally, wrapper functions are defined to simplify
     the construction of 'Image' objects in different situations: the
     default  constructor, 'Image', the 'readImage' constructor that
     creates an object from reading image files and the 'copy'
     constructor.

_A_c_c_e_s_s_o_r _m_e_t_h_o_d_s:

     Accessor methods are class methods that are defined to retrieve
     data values  from objects of a given class or to assigne those.
     These should be used instead of directly referring to the slots.
     Unfortunately, R does not have a concept  of private or protected
     class members: all slots have "public" access in terms of other
     object-oriented languages. Therefore, data encapsulation in sense
     of hiding the particular structure of the class is impossible. At
     the same time, it is still recommended to use accessor functions
     instead of directly accessing slots. One can also assume that any
     slot that does not have an accessor method should not be accessed
     directly by the user.

     The following accessor methods are defined as S4 methods for class
     'Image':



     '_c_o_l_o_r_M_o_d_e(_x)', '_c_o_l_o_r_M_o_d_e(_x) <- _v_a_l_u_e' Gets and sets image color
          mode. 'value' is one of the constants above. Default:
          'Grayscale'. 

     '_c_o_m_p_r_e_s_s_i_o_n(_x)', '_c_o_m_p_r_e_s_s_i_o_n(_x) <- _v_a_l_u_e' Gets and sets
          compression algorithm used when image saved in a format
          supporting compression. For exapmple, TIFF images support ZIP
          and LZW lossless compressions, whereas JPEG uses JPEG
          compression by default. Possible values of type 'character'
          are ''NONE', 'LZW', 'ZIP', 'JPEG', 'BZIP'' and ''GROUP4''.
          Some of these may be unavailable on your system if
          'ImageMagick' was compiles without their support. Default:
          ''LZW''. 

     '_f_e_a_t_u_r_e_s(_x)' Is a read only method that returns a 'list' or
          matrices with descriptors of detected objects. If object
          detection was executed on the image, an empty list is
          returned. Otherwise, the number of elements matches the
          number of frames in the image. Default: 'list()'. 

     '_f_i_l_e_N_a_m_e(_x)', '_f_i_l_e_N_a_m_e(_x) <- _v_a_l_u_e' Gets and sets the file name.
          When reading images this value is updated, when writing it
          can be used as default if no alternative is specified. When
          reading a stack, the first file name in the list of stack
          images will be assigned. Default: ''no-name''. 

     '_i_m_a_g_e_D_a_t_a(_x)', '_i_m_a_g_e_D_a_t_a(_x) <- _v_a_l_u_e' Gets and sets image data.
          Image data is a 3D array with the last dimension matching the
          number of 2D images in a stack. The atomic type of the array
          is defined by 'colorMode()'. 

     '_r_e_s_o_l_u_t_i_o_n(_x)', '_r_e_s_o_l_u_t_i_o_n(_x) <- _v_a_l_u_e' Gets and sets values of
          image resoultion: a numeric vector of two values of
          resolution in 'x' and 'y' dimensions. Generally resolution is
          understood in pixel-per-inch (ppi) or dots-per-inch (dpi),
          however some microscopes can save these values in images in
          different units. It is the responsibility of the user to
          identify the unit and keep the units comparable between
          different images in the same project if required: the package
          does not take care of this. The default values are equal for
          both directions, 2.5e+6 dpi. 


_D_e_t_a_i_l_s:

     Image data are stored as 3D arrays with first two dimensions
     specifying  frame size and third the number of frames. A single 2D
     image has the number of  frames 1. In subsetting, the value of
     'drop' parameter is set to  'FALSE', thus image dimensionality is
     preserved at 3.

     'Image' is derived from 'array', therefore, the data is stored in
     arrays. 'Image' can store either grayscale or true color data at
     the moment. Grayscale data is stored in 'numeric' arrays, whereas
     true color data is stored in 'integer' arrays. Correspondingly,
     the data  is created with 'array(as.numeric(val),dim(val))' for
     grayscale and 'array(as.integer(val),dim(val))' for true color
     images. Grayscale values are assumed to be in the range '[0,1]',
     although this is not a requirement in sense of data storage.
     Although, many image processing functions will  assume data in
     this range or will generate invalid results for the data out of 
     this range.

_A_u_t_h_o_r(_s):

     Oleg Sklyar, osklyar@ebi.ac.uk, 2005-2007

_S_e_e _A_l_s_o:

     ' Image, IndexedImage, display, channel,  image,Image-method,
     show,Image-method,  '

_E_x_a_m_p_l_e_s:

       ## New Grayscale image of a black-to-white vertical gradient
       w <- 120
       a <- Image((0:(w^2))/w^2, c(w,w))
       if ( interactive() ) display(a)
       print(a)

       ## Converts image to TrueColor
       b <- a
       colorMode(b) <- TrueColor
       print(b)

       ## Fills values with intensities over 0.5 (50%) with red
       b[ a > 0.5 ] = as.integer(255)
       if ( interactive() ) display(b)

