def getForegroundTiles(self, bgcolor=None):
        
        #binary mask selecting foreground regions
        mask = self._fgMask.asOpenCVBW()
        if mask == None: return None
        
        #full color source image
        image = self._annotateImg.copy().asOpenCV()
        
        #dest image, full color, but initially all zeros (black/background)
        # we will copy the foreground areas from image to here.
        dest = cv.CloneImage(image)
        if bgcolor==None:
            cv.SetZero(dest)
        else:
            cv.Set(dest, cv.RGB(*bgcolor))
            
        cv.Copy(image,dest,mask) #copy only pixels from image where mask != 0
        dst = pv.Image(dest)
        
        rects = self.getRects()
        
        tiles = []
        for r in rects:
            #for every rectangle, crop from dest image
            t = dst.crop(r)
            tiles.append(t)
            
        return tiles
Initialize the graph's data structures:
dataset/ETHPy150Open bolme/pyvision/src/pyvision/surveillance/MotionDetector.py/MotionDetector.getForegroundTiles--crossover with--dataset/ETHPy150Open dnlcrl/PyGraphArt/src/graph.py/Graph.__init__