Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I am experimenting with the Eigenfaces algorithm and have my notes and experimental data collected in a Mathematica notebook. The result of an experimental run is a table of scores, where the smallest score corresponds to the best match of the facial signatures in the database. For example, a test run that matches three "unclassified" face images against a database that contains nine signatures produces a 3x9 list of scores like the following:

{{127.579, 99.0273, 29.9504, 34.6636, 18.359, 76.6986, 118.535, 87.1991, 110.594},
 {190.249, 155.089, 75.9139, 118.029, 100.344, 22.9319, 28.5625, 13.7456, 36.53},
 {102.811, 80.8411, 58.3028, 26.0953, 31.6592, 107.468, 148.969, 117.58, 142.881}}

I display this in TableForm to make it easier to read.

I would like to add a column of headers to the resulting table so that each column is headed by the image that generated the signature at that column in the database. And likewise, I would like to add row headers so that each row is headed by the face image that generated that row of scores.

For added coolness, it would be nice to highlight the minimum in each row somehow in the output (such as rendering it in a different color).

I suspect Mathematica can do all of this but I'm at a loss as to exactly how. Any suggestions?

UPDATE: Here is an example of the output formatted using the accepted answer below:


share|improve this question
add comment

1 Answer

up vote 11 down vote accepted

You can use the TableHeadings option to supply the row and column headings (which can also be images). Here's an example (data is the matrix in your question):

lena = ImageResize[ExampleData[{"TestImage", "Lena"}], {64, 64}];
TableForm[With[{min = Min[#]}, # /. min -> Style[min, Red]] & /@ data, 
    TableHeadings -> {ConstantArray[lena, 3], ConstantArray[lena, 9]}]

enter image description here

share|improve this answer
Awesome! Much easier than I expected, thanks! –  Kaelin Colclasure Apr 28 '12 at 23:26
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.