'Get median pixel level for each layer'

def _getmedian(self):

    v = []
    for i in self.bands:
        s = 0
        l = (self.count[i] // 2)
        b = (i * 256)
        for j in range(256):
            s = (s + self.h[(b + j)])
            if (s > l):
                break
        v.append(j)
    return v
