Re: Flatten and BlockProcessing

• To: mathgroup at smc.vnet.net
• Subject: [mg65661] Re: Flatten and BlockProcessing
• Date: Wed, 12 Apr 2006 06:00:14 -0400 (EDT)
• Sender: owner-wri-mathgroup at wolfram.com

```On 4/11/06 at 4:04 AM, maarten.vanderburgt at icos.be (Maarten van der
Burgt) wrote:

>I have a structure M:

>M = {{{{a, b}, {e, f}}, {{c, d}, {g, h}}}, {{{k, l}, {o, p}}, {{m,
>n}, {q, r}}}}

>M//Dimensions

>gives

>{2, 2, 2, 2},

>(or more general {n1, n2, m1, m2}; M is the result of the
>BlockProcessing function from the Image Processing package)

>Does anyone know an elegant way of 'flattening' M to give

>{{a, b, c, d}, {e, f, g, h}, {k, l, m, n}, {o, p, q, r}}

>with dimensions {4, 4} (or more general {n1*m1, n2*m2})?

Elegance often depends on the user. But the following will do what you want for the example given

In[21]:=
M = {{{{a, b}, {e, f}}, {{c, d}, {g, h}}},
{{{k, l}, {o, p}}, {{m, n}, {q, r}}}};

Join@@@Flatten[Transpose[M, {1, 3, 2}], 1]

Out[22]=
{{a, b, c, d}, {e, f, g, h}, {k, l, m, n}, {o, p, q, r}}
--
To reply via email subtract one hundred and four

```

• Prev by Date: Re: Flatten and BlockProcessing
• Next by Date: Re: Flatten and BlockProcessing
• Previous by thread: Re: Flatten and BlockProcessing
• Next by thread: Re: Flatten and BlockProcessing