'**SUMMARY**
Casts each in the image set into a 32F image, averages them together and returns the results.
If the images are different sizes the method attempts to standarize them.
**PARAMETERS**
* *mode* -
* "first" - resize everything to the size of the first image.
* "max" - resize everything to be the max width and max height of the set.
* "min" - resize everything to be the min width and min height of the set.
* "average" - resize everything to be the average width and height of the set
* "fixed" - fixed, use the size tuple provided.
* *size* - if the mode is set to fixed use this tuple as the size of the resulting image.
**RETURNS**
Returns a single image that is the average of all the values.
**EXAMPLE**
>>> imgs = ImageSet()
>>> imgs.load("images/faces")
>>> result = imgs.average(mode="first")
>>> result.show()
**TODO**
* Allow the user to pass in an offset parameters that blit the images into the resutl.'

def average(self, mode='first', size=(None, None)):

    fw = 0
    fh = 0
    if (len(self) <= 0):
        return ImageSet()
    vals = self.dimensions()
    if (mode.lower() == 'first'):
        fw = self[0].width
        fh = self[0].height
    elif (mode.lower() == 'fixed'):
        fw = size[0]
        fh = size[1]
    elif (mode.lower() == 'max'):
        fw = np.max(vals[:, 0])
        fh = np.max(vals[:, 1])
    elif (mode.lower() == 'min'):
        fw = np.min(vals[:, 0])
        fh = np.min(vals[:, 1])
    elif (mode.lower() == 'average'):
        fw = int(np.average(vals[:, 0]))
        fh = int(np.average(vals[:, 1]))
    t1 = np.sum((vals[:, 0] - fw))
    t2 = np.sum((vals[:, 1] - fh))
    if ((t1 != 0) or (t2 != 0)):
        resized = self.standardize(fw, fh)
    else:
        resized = self
    accumulator = cv.CreateImage((fw, fh), cv.IPL_DEPTH_8U, 3)
    cv.Zero(accumulator)
    alpha = float((1.0 / len(resized)))
    beta = float(((len(resized) - 1.0) / len(resized)))
    for i in resized:
        cv.AddWeighted(i.getBitmap(), alpha, accumulator, beta, 0, accumulator)
    retVal = Image(accumulator)
    return retVal
