title: How do you turn a .png file into a 2-d matrix?
body: <p>I am working on a project for a Bio-medical Imaging course (Note: it is a non-programming course, so asking for programming help is not cheating.  Asking for conceptual help with planning would be cheating.) where I need to manipulate an image using different mathematical transforms.  I am writing in C so it can be as fast as possible.  I have finished the code for the mathematical transforms, but I have realized that I do not know how to turn a grayscale .png file into a 2-d matrix/array to compute with, and I do not know how to display a .png file in C.  Can anyone help me?</p>
  
  <p>I'm trying to turn the "image.png" image into a 2d array where each entry in the array has a value between 0 - 255 and corresponds with each pixel in "image.png".  I also want to turn a 2d array where each entry corresponds to a pixel in the image and has a value between 0 - 255 into a new "image_two.png" file.    </p>
  
  <p>I'm a somewhat new programmer.  I have a solid base in python programming, but C is new for me.  I have done a lot of research and I have found a lot of people talking about using <a href="http://sourceforge.net/projects/pnglite/" rel="noreferrer">"this library"</a> or <a href="http://lodev.org/lodepng/" rel="noreferrer">"that library"</a>, or also <a href="http://www.libpng.org/pub/png/libpng.html" rel="noreferrer">"this library"</a>, but how do I use a downloaded library in C?  It's unfamiliar territory for me as a python programmer :(</p>
  
  <p>I'm using Ubuntu 12.04</p>
  
  <p>To reiterate:</p>
  
  <ul>
  <li><p>How do you read a grayscale .png image as a 2-d array/matrix in C?  </p></li>
  <li><p>How do you display a 2-d array/matrix as a grayscale image in C?</p></li>
  <li><p><strike>How do you use a downloaded library in C code (specifically for the two questions above)?</strike> I found out how to use these libraries.</p></li>
  </ul>
  
  <p>EDIT: I am still having trouble figuring out how to create a grayscale 2d array out of a .png file and how to make a .png file out of a grayscale 2d matrix.  Can anyone else help?</p>