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

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -