'**SUMMARY**
Do a 1D threshold operation. Values about the threshold
will be set to 255, values below the threshold will be
set to 0. If invert is true we do the opposite.
**PARAMETERS**
* *threshold* - The cutoff value for our threshold.
* *invert* - if invert is false values above the threshold
are set to 255, if invert is True the are set to 0.
**RETURNS**
The thresholded linescan operation.
**EXAMPLE**
>>>> ls = img.getLineScan(x=10)
>>>> ls2 = ls.threshold()
>>>> plt.plot(ls)
>>>> plt.plot(ls2)
>>>> plt.show()'

def threshold(self, threshold=128, invert=False):

    out = []
    high = 255
    low = 0
    if invert:
        high = 0
        low = 255
    for pt in self:
        if (pt < threshold):
            out.append(low)
        else:
            out.append(high)
    retVal = LineScan(out, image=self.image, pointLoc=self.pointLoc, pt1=self.pt1, pt2=self.pt2)
    retVal._update(self)
    return retVal
