#NEWLINE# def labelmeanfilter_nd( y , x ) : #NEWLINE# #INDENT# labelsunique = np . arange ( ( np . max ( y ) + 1 ) ) #NEWLINE# labmeansdata = [ ] #NEWLINE# labmeans = [ ] #NEWLINE# for xx in x . T : #NEWLINE# #INDENT# labelmeans = np . array ( ndimage . mean ( xx , labels = y , index = labelsunique ) ) #NEWLINE# labmeansdata . append ( labelmeans [ y ] ) #NEWLINE# labmeans . append ( labelmeans ) #NEWLINE# #UNINDENT# labelcount = np . array ( ndimage . histogram ( y , labelsunique [ 0 ] , ( labelsunique [ ( - 1 ) ] + 1 ) , 1 , labels = y , index = labmeansdata ) ) #NEWLINE# return ( labelcount , np . array ( labmeans ) , np . array ( labmeansdata ) . T )