On Thu, Jul 22, 2010 at 9:59 PM, Ian Mallett <[email protected]> wrote:
> Hi again, > > I've condensed the problem down a lot, because I both presented it in an > overcomplicated way, and did not explain it particularly well. > > Condensed problem: > a = np.zeros(num_patches) > b = np.array(...) #created, and is size 512^512 = 262,144 > #Each value in "b" is an index into "a". > #For each occurrence of a given index in "b", increment the corresponding > value in "a" by +1. > #How should I do that? > > Simpler, and more importantly, better explained problem. Help? > > Is that what you want, or do you just want to know how many unique indices there are? As to encoding the RGB, unless there is a existing program your best bet is probably to use a dot product, i.e., if pix_data is (n,3) uint8, then pix_index = np.dot(pix_data, array([1, 2**8, 2**16], dtype=uint32) then check out the documentation for np.unique. Chuck
_______________________________________________ NumPy-Discussion mailing list [email protected] http://mail.scipy.org/mailman/listinfo/numpy-discussion
