Re: Convert Binary Image to Column Vector
- To: mathgroup at smc.vnet.net
- Subject: [mg83972] Re: Convert Binary Image to Column Vector
- From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
- Date: Thu, 6 Dec 2007 02:35:52 -0500 (EST)
- Organization: The Open University, Milton Keynes, UK
- References: <fj65hr$fp1$1@smc.vnet.net>
Tara.Ann.Lorenz at gmail.com wrote: > Can a 30x30 binary image be converted directly into a column vector of > 900 components in Mathematica? Yes. Either Flatten@t1 or Flatten@Transpose@t1 will do the job, though the elements will be put in different order (see an example below). > Or must the image first be put into matrix form? No. And if by "matrix form" you mean MatrixForm, never do that for MatrixForm must be reserved just for display purpose. > I am using the command: > Flatten@Transpose@t1, where t1 is my binary image, and it seems to > give me a vector but I'm not sure if it's the one that I desire. The following examples illustrate the differences between the outputs produced by Flatten@t1 and Flatten@Transpose@t1, respectively. Mathematica 6.0 for Microsoft Windows (32-bit) Copyright 1988-2007 Wolfram Research, Inc. In[1]:= t1 = {{a, b}, {c, d}}; In[2]:= t1 // MatrixForm Out[2]//MatrixForm= a b c d In[3]:= Flatten@t1 Out[3]= {a, b, c, d} In[4]:= Flatten@Transpose@t1 Out[4]= {a, c, b, d} <snip> Regards, -- Jean-Marc