Numpy set range where less than -


def updatemap(depthmap, p1, p2, value):     maps = depthmap[0:580,p1[0]:p2[0]]     maps[maps < value] = value     depthmap[0:580,p1[0]:p2[0]] = maps 

this current way it. requires make copy of range, set range value less than, copy back. copying make slow. there syntax can use?

assuming depthmap numpy array, part:

maps = depthmap[0:580,p1[0]:p2[0]] 

doesn't make copy. unlike lists , tuples, numpy slicing creates view of original array. thus, next line:

maps[maps < value] = value 

modifies original depthmap array, , line after that:

depthmap[0:580,p1[0]:p2[0]] = maps 

is superfluous. can remove it:

def updatemap(depthmap, p1, p2, value):     maps = depthmap[0:580,p1[0]:p2[0]]     maps[maps < value] = value 

Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

Kivy: Swiping (Carousel & ScreenManager) -