[Numpy-discussion] meaning of accumulation/normalisation

wilson wilson.t.thompson@gmail....
Thu Apr 10 17:18:17 CDT 2008


hi
i came across some image processing code in java and tried to
duplicate the operation on an ndarray.the array is supposed to contain
pixel values of a gryscale image generated by the program. however the
code does some accumulation operation as below to obtain a value
'norm'

ul=array(([....],[....]....,[...])) #containing float values

def accumOperation(ul):
	nr,nc=ul.shape
	print "nr:",nr,"nc:",nc
	val=0.0
	for r in range(nr):
		for c in range(nc):
			val+=ul[r][c]*ul[r][c]
	return val
norm=accumOperation(ul)
newul=ul/norm

the java doc mentions that by the above steps ul is normalised to unit
length (vector length)
can someone explain this?it is not very clear to me and (i am trying
to understand the code by reading and tying out in debugger.. the
newul array content is then used to generate a pgm image in the code)

thanks
W





More information about the Numpy-discussion mailing list