'**SUMMARY**
This method tries to fit a list of points to lines in the image. The list of points
is a list of (x,y) tuples that are near (i.e. within the window size) of the line
you want to fit in the image. This method uses a binary such as the result of calling
edges.
This method is based on active contours. Please see this reference:
http://en.wikipedia.org/wiki/Active_contour_model
**PARAMETERS**
* *initial_curve* - region of the form [(x0,y0),(x1,y1)...] that are the initial conditions to fit.
* *window* - the search region around each initial point to look for a solution.
* *params* - The alpha, beta, and gamma parameters for the active contours
algorithm as a list [alpha,beta,gamma].
* *doAppx* - post process the snake into a polynomial approximation. Basically
this flag will clean up the output of the contour algorithm.
* *appx_level* - how much to approximate the snake, higher numbers mean more approximation.
**DISCUSSION**
THIS SECTION IS QUOTED FROM: http://users.ecs.soton.ac.uk/msn/book/new_demo/Snakes/
There are three components to the Energy Function:
* Continuity
* Curvature
* Image (Gradient)
Each Weighted by Specified Parameter:
Total Energy = Alpha*Continuity + Beta*Curvature + Gamma*Image
Choose different values dependent on Feature to extract:
* Set alpha high if there is a deceptive Image Gradient
* Set beta  high if smooth edged Feature, low if sharp edges
* Set gamma high if contrast between Background and Feature is low
**RETURNS**
A list of (x,y) tuples that approximate the curve. If you do not use
approximation the list should be the same length as the input list length.
**EXAMPLE**
>>> img = Image("lenna")
>>> edges = img.edges(t1=120,t2=155)
>>> guess = [(311,284),(313,270),(320,259),(330,253),(347,245)]
>>> result = edges.fitContour(guess)
>>> img.drawPoints(guess,color=Color.RED)
>>> img.drawPoints(result,color=Color.GREEN)
>>> img.show()'

def fitContour(self, initial_curve, window=(11, 11), params=(0.1, 0.1, 0.1), doAppx=True, appx_level=1):

    alpha = [params[0]]
    beta = [params[1]]
    gamma = [params[2]]
    if ((window[0] % 2) == 0):
        window = ((window[0] + 1), window[1])
        logger.warn('Yo    dawg,    just    a    heads    up,    snakeFitPoints    wants    an    odd    window    size.    I    fixed    it    for    you,    but    you    may    want    to    take    a    look    at    your    code.')
    if ((window[1] % 2) == 0):
        window = (window[0], (window[1] + 1))
        logger.warn('Yo    dawg,    just    a    heads    up,    snakeFitPoints    wants    an    odd    window    size.    I    fixed    it    for    you,    but    you    may    want    to    take    a    look    at    your    code.')
    raw = cv.SnakeImage(self._getGrayscaleBitmap(), initial_curve, alpha, beta, gamma, window, (cv.CV_TERMCRIT_ITER, 10, 0.01))
    if doAppx:
        try:
            import cv2
        except:
            logger.warning("Can't    Do    snakeFitPoints    without    OpenCV    >=    2.3.0")
            return
        appx = cv2.approxPolyDP(np.array([raw], 'float32'), appx_level, True)
        retVal = []
        for p in appx:
            retVal.append((int(p[0][0]), int(p[0][1])))
    else:
        retVal = raw
    return retVal
