2009/7/15 David Warde-Farley <d...@cs.toronto.edu>:
> Here's an interesting problem, and it might've already been solved by
> some of you folks that do image processing:
>
> Suppose I have an 8-bit integer 2-d array, X, and I want a 256x256
> matrix that tells me how many times a pixel value v was horizontally
> (along second dimension) adjacent to a pixel value b.
>
> So,  in an array [[1, 2, 1],[1,1,2],[1,0,0]] the upper left 3x3 square
> would be [[1, 1, 0], [1, 1, 3], [0, 3, 0]] with the rest of the matrix
> 0.
>
> Is there an efficient way to do such a thing with numpy operations? I
> can't think of a way.

You can also have a look at the gray-level co-occurrence matrix code here:

http://mentat.za.net/cgi-bin/hgwebdir.cgi/greycomatrix/

Regards
Stéfan
_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to