[Numpy-discussion] Adjacent matrix

Thiago Franco Moraes totonixsame@gmail....
Wed Jun 15 07:31:40 CDT 2011


On Tue, Jun 14, 2011 at 6:30 PM, Gael Varoquaux
<gael.varoquaux@normalesup.org> wrote:
> On Tue, Jun 14, 2011 at 10:29:38AM -0300, Thiago Franco Moraes wrote:
>> I don't know if I understand. The idea is to use _make_edges_3d to
>> give me the connectivity, isn't it? Like for example, a 3x3 image:
>
>> 0, 1, 2
>> 3, 4, 5
>> 6, 7, 8
>
>> If I use _make_edges_3d(3, 3) I get:
>
>> array([[0, 1, 3, 4, 6, 7, 0, 1, 2, 3, 4, 5],
>>        [1, 2, 4, 5, 7, 8, 3, 4, 5, 6, 7, 8]])
>
>> So, for example, the pixel 4 is connected with 3, 5, 7 and 1
>> (connectivity 4). Is it?
>
> Yes, you go the idea.
>
>> The problem is I need to work with connectivity 26 in 3D images, or 8
>> in 2D images. I'm not able to understand the code so well to apply to
>> those connectivity I said (8 and 26).
>
> The code is for 4 connectivity (or 6 in 3D). You will need to modify the
> _make_edges_3d function to get the connectivity you want. Hopefully this
> will get the ball running, and by looking at the code you will figure out
> how to modify it.
>
> HTH,
>
> Gaël

Thanks Gaël. To resolve my problem I'm using mahotas.labeled.borders
which was proposed by Luis. However, the ideas from _make_edges_3d can
be useful to me in other problems I'm having. Thanks again.


More information about the NumPy-Discussion mailing list