<s> from SimpleCV . base import * <EOL> from SimpleCV . Features import Feature , FeatureSet , BlobMaker <EOL> from SimpleCV . ColorModel import ColorModel <EOL> from SimpleCV . Color import Color <EOL> from SimpleCV . ImageClass import Image <EOL> from SimpleCV . Segmentation . SegmentationBase import SegmentationBase <EOL> class ColorSegmentation ( SegmentationBase ) : <EOL> """<STR_LIT>""" <EOL> mColorModel = [ ] <EOL> mError = False <EOL> mCurImg = [ ] <EOL> mTruthImg = [ ] <EOL> mBlobMaker = [ ] <EOL> def __init__ ( self ) : <EOL> self . mColorModel = ColorModel ( ) <EOL> self . mError = False <EOL> self . mCurImg = Image ( ) <EOL> self . mTruthImg = Image ( ) <EOL> self . mBlobMaker = BlobMaker ( ) <EOL> def addImage ( self , img ) : <EOL> """<STR_LIT>""" <EOL> self . mTruthImg = img <EOL> self . mCurImg = self . mColorModel . threshold ( img ) <EOL> return <EOL> def isReady ( self ) : <EOL> """<STR_LIT>""" <EOL> return True ; <EOL> def isError ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . mError <EOL> def resetError ( self ) : <EOL> """<STR_LIT>""" <EOL> self . mError = false <EOL> return <EOL> def reset ( self ) : <EOL> """<STR_LIT>""" <EOL> self . mColorModel . reset ( ) <EOL> def getRawImage ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . mCurImg <EOL> def getSegmentedImage ( self , whiteFG = True ) : <EOL> """<STR_LIT>""" <EOL> return self . mCurImg <EOL> def getSegmentedBlobs ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . mBlobMaker . extractFromBinary ( self . mCurImg , self . mTruthImg ) <EOL> def addToModel ( self , data ) : <EOL> self . mColorModel . add ( data ) <EOL> def subtractModel ( self , data ) : <EOL> self . mColorModel . remove ( data ) <EOL> def __getstate__ ( self ) : <EOL> mydict = self . __dict__ . copy ( ) <EOL> self . mBlobMaker = None <EOL> del mydict [ '<STR_LIT>' ] <EOL> return mydict <EOL> def __setstate__ ( self , mydict ) : <EOL> self . __dict__ = mydict <EOL> self . mBlobMaker = BlobMaker ( ) </s>
