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

timeout - Handshake_timeout on RabbitMQ using python and pika from remote vm -

gcc - MinGW's ld cannot perform PE operations on non PE output file -

c# - Search and Add Comment with OpenXML for Word -