Mathematica mini memo – Element-wise operations

I find matrices in Mathematica to be a little tricky. They are not strictly matrices, more like lists of lists. Here is a short example of manipulation of a 3d matrix. If we have a file of image data representing multiple images (i.e. multiple 2d matrices)  we can manipulate them using the Map function. So for a set of data as follows

we use  Map[Image[#,"byte"]&, data] to get 


Where the function Image represents each element in the data file as a pixel, with the option “byte” specifying the data format and # representing the function argument (in this case # = data).

About these ads

One response to “Mathematica mini memo – Element-wise operations

  1. Pingback: Mathematica Memo – How to import multiple data files into a single variable. | Christina's Blog of Miscellanies and Accelerator Physics

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s