'**SUMMARY**
The constructor takes a single polymorphic parameter, which it tests
to see how it should convert into an RGB image.  Supported types include:
**PARAMETERS**
* *source* - The source of the image. This can be just about anything, a numpy arrray, a file name, a width and height
tuple, a url. Certain strings such as "lenna" or "logo" are loaded automatically for quick testing.
* *camera* - A camera to pull a live image.
* *colorspace* - A default camera color space. If none is specified this will usually default to the BGR colorspace.
* *sample* - This is set to true if you want to load some of the included sample images without having to specify the complete path
**EXAMPLES**
>>> img = Image(\'simplecv\')
>>> img = Image(\'test.png\')
>>> img = Image(\'http://www.website.com/my_image.jpg\')
>>> img.show()
**NOTES**
OpenCV: iplImage and cvMat types
Python Image Library: Image type
Filename: All opencv supported types (jpg, png, bmp, gif, etc)
URL: The source can be a url, but must include the http://'

def __init__(self, source=None, camera=None, colorSpace=ColorSpace.UNKNOWN, verbose=True, sample=False, cv2image=False, webp=False):

    self._mLayers = []
    self.camera = camera
    self._colorSpace = colorSpace
    self._mKeyPoints = []
    self._mKPDescriptors = []
    self._mKPFlavor = 'NONE'
    self._mDoHuePalette = False
    self._mPaletteBins = None
    self._mPalette = None
    self._mPaletteMembers = None
    self._mPalettePercentages = None
    self._tempFiles = []
    if (isinstance(source, basestring) and (source.lower().startswith('http://') or source.lower().startswith('https://'))):
        req = urllib2.Request(source, headers={'User-Agent': 'Mozilla/5.0    (Macintosh;    Intel    Mac    OS    X    10_7_4)    AppleWebKit/536.5    (KHTML,    like    Gecko)    Chrome/19.0.1084.54    Safari/536.5'})
        img_file = urllib2.urlopen(req)
        im = StringIO(img_file.read())
        source = pil.open(im).convert('RGB')
    if (isinstance(source, basestring) and source.lower().startswith('data:image/png;base64,')):
        img = source[22:].decode('base64')
        im = StringIO(img)
        source = pil.open(im).convert('RGB')
    if isinstance(source, basestring):
        tmpname = source.lower()
        if ((tmpname == 'simplecv') or (tmpname == 'logo')):
            imgpth = os.path.join(LAUNCH_PATH, 'sampleimages', 'simplecv.png')
            source = imgpth
        elif ((tmpname == 'simplecv_inverted') or (tmpname == 'inverted') or (tmpname == 'logo_inverted')):
            imgpth = os.path.join(LAUNCH_PATH, 'sampleimages', 'simplecv_inverted.png')
            source = imgpth
        elif (tmpname == 'lenna'):
            imgpth = os.path.join(LAUNCH_PATH, 'sampleimages', 'lenna.png')
            source = imgpth
        elif (tmpname == 'lyle'):
            imgpth = os.path.join(LAUNCH_PATH, 'sampleimages', 'LyleJune1973.png')
            source = imgpth
        elif (tmpname == 'parity'):
            choice = random.choice(['LyleJune1973.png', 'lenna.png'])
            imgpth = os.path.join(LAUNCH_PATH, 'sampleimages', choice)
            source = imgpth
        elif sample:
            imgpth = os.path.join(LAUNCH_PATH, 'sampleimages', source)
            source = imgpth
    if (type(source) == tuple):
        w = int(source[0])
        h = int(source[1])
        source = cv.CreateImage((w, h), cv.IPL_DEPTH_8U, 3)
        cv.Zero(source)
    if (type(source) == cv.cvmat):
        self._matrix = cv.CreateMat(source.rows, source.cols, cv.CV_8UC3)
        if ((source.step / source.cols) == 3):
            cv.Copy(source, self._matrix, None)
            self._colorSpace = ColorSpace.BGR
        elif ((source.step / source.cols) == 1):
            cv.Merge(source, source, source, None, self._matrix)
            self._colorSpace = ColorSpace.GRAY
        else:
            self._colorSpace = ColorSpace.UNKNOWN
            warnings.warn('Unable    to    process    the    provided    cvmat')
    elif (type(source) == np.ndarray):
        if (type(source[(0, 0)]) == np.ndarray):
            source = source.astype(np.uint8)
            self._numpy = source
            if (not cv2image):
                invertedsource = source[:, :, ::(-1)].transpose([1, 0, 2])
            else:
                invertedsource = source
            self._bitmap = cv.CreateImageHeader((invertedsource.shape[1], invertedsource.shape[0]), cv.IPL_DEPTH_8U, 3)
            cv.SetData(self._bitmap, invertedsource.tostring(), ((invertedsource.dtype.itemsize * 3) * invertedsource.shape[1]))
            self._colorSpace = ColorSpace.BGR
        else:
            source = source.astype(np.uint8)
            if (not cv2image):
                source = source.transpose([1, 0])
            self._bitmap = cv.CreateImage((source.shape[1], source.shape[0]), cv.IPL_DEPTH_8U, 3)
            channel = cv.CreateImageHeader((source.shape[1], source.shape[0]), cv.IPL_DEPTH_8U, 1)
            cv.SetData(channel, source.tostring(), (source.dtype.itemsize * source.shape[1]))
            cv.Merge(channel, channel, channel, None, self._bitmap)
            self._colorSpace = ColorSpace.BGR
    elif (type(source) == cv.iplimage):
        if (source.nChannels == 1):
            self._bitmap = cv.CreateImage(cv.GetSize(source), source.depth, 3)
            cv.Merge(source, source, source, None, self._bitmap)
            self._colorSpace = ColorSpace.GRAY
        else:
            self._bitmap = cv.CreateImage(cv.GetSize(source), source.depth, 3)
            cv.Copy(source, self._bitmap, None)
            self._colorSpace = ColorSpace.BGR
    elif ((type(source) == type(str())) or (source.__class__.__name__ == 'StringIO')):
        if (source == ''):
            raise IOError('No    filename    provided    to    Image    constructor')
        elif (webp or (source.split('.')[(-1)] == 'webp')):
            try:
                if (source.__class__.__name__ == 'StringIO'):
                    source.seek(0)
                self._pil = pil.open(source)
                self._bitmap = cv.CreateImageHeader(self._pil.size, cv.IPL_DEPTH_8U, 3)
            except:
                try:
                    from webm import decode as webmDecode
                except ImportError:
                    logger.warning('The    webm    module    or    latest    PIL    /    PILLOW    module    needs    to    be    installed    to    load    webp    files:    https://github.com/sightmachine/python-webm')
                    return
                WEBP_IMAGE_DATA = bytearray(file(source, 'rb').read())
                result = webmDecode.DecodeRGB(WEBP_IMAGE_DATA)
                webpImage = pil.frombuffer('RGB', (result.width, result.height), str(result.bitmap), 'raw', 'RGB', 0, 1)
                self._pil = webpImage.convert('RGB')
                self._bitmap = cv.CreateImageHeader(self._pil.size, cv.IPL_DEPTH_8U, 3)
                self.filename = source
            cv.SetData(self._bitmap, self._pil.tostring())
            cv.CvtColor(self._bitmap, self._bitmap, cv.CV_RGB2BGR)
        else:
            self.filename = source
            try:
                self._bitmap = cv.LoadImage(self.filename, iscolor=cv.CV_LOAD_IMAGE_COLOR)
            except:
                self._pil = pil.open(self.filename).convert('RGB')
                self._bitmap = cv.CreateImageHeader(self._pil.size, cv.IPL_DEPTH_8U, 3)
                cv.SetData(self._bitmap, self._pil.tostring())
                cv.CvtColor(self._bitmap, self._bitmap, cv.CV_RGB2BGR)
            self._colorSpace = ColorSpace.BGR
    elif (type(source) == pg.Surface):
        self._pgsurface = source
        self._bitmap = cv.CreateImageHeader(self._pgsurface.get_size(), cv.IPL_DEPTH_8U, 3)
        cv.SetData(self._bitmap, pg.image.tostring(self._pgsurface, 'RGB'))
        cv.CvtColor(self._bitmap, self._bitmap, cv.CV_RGB2BGR)
        self._colorSpace = ColorSpace.BGR
    elif (PIL_ENABLED and ((len(source.__class__.__bases__) and (source.__class__.__bases__[0].__name__ == 'ImageFile')) or (source.__class__.__name__ == 'JpegImageFile') or (source.__class__.__name__ == 'WebPPImageFile') or (source.__class__.__name__ == 'Image'))):
        if (source.mode != 'RGB'):
            source = source.convert('RGB')
        self._pil = source
        self._bitmap = cv.CreateImageHeader(self._pil.size, cv.IPL_DEPTH_8U, 3)
        cv.SetData(self._bitmap, self._pil.tostring())
        self._colorSpace = ColorSpace.BGR
        cv.CvtColor(self._bitmap, self._bitmap, cv.CV_RGB2BGR)
    else:
        return None
    if (colorSpace != ColorSpace.UNKNOWN):
        self._colorSpace = colorSpace
    bm = self.getBitmap()
    self.width = bm.width
    self.height = bm.height
    self.depth = bm.depth
