If we had convenient ways of displaying images with non-square pixels, this would not be a problem. But this is not part of how PNG images are normally displayed: web browsers will assume 1:1 aspect ratio, which causes the images to look distorted.
To counter-act this, you can create a new image, which resamples the information represented by the old image, on a grid that does have 1:1 aspect ratio. The new image can be readily displayed with a web browser or whatever else you're using to look at images. "Fast and Slow axes in PNG" One thing that should have been included in the Project 2 assignment was a statement of which axes in PNG images are fast and slow. Here is a small 16-bit grayscale image (just like the image datasets) that may be useful for experimenting with:
There are 30 samples on the fast axis, and 20 samples on the slow axis. Some people might say this is a "30 by 20 image", or, a "20 by 30 matrix". The values in the images are 1000, 2000, 3000, 4000, 5000, and 6000, in 10x10 pixel blocks. In a normal display of the image (see Web browsers as image viewers), [slow/fast typo fixed Oct 14] the![]()
Web browsers can be trusted to display PNG images in a consistent way (see Fast vs Slow above), so they make a sensible reference for the "correct" way they are displayed. They are also a ubiquitous and convenient way of viewing images. Most other image-viewing programs, and things like Gimp and Photoshop, will also display the images in this orientation, though they may be less convenient to view an image that is being repeatedly updated as you debug your program (in the browser, you can just hit refresh).
If you are using something like Matlab or Pylab to complete the
assingment, you may find that the easiest way of displaying images
within those programs doesn't match the way that web browsers do.
This is a wrinkle that will be up to you to work around. The images
as they appear in your write-up must be in the correct orientation.
Example Python/Numpy/PIL code
You may find it convenient to
use Python for this assignment,
because of its associated Numpy
and PIL
libraries. Here are some simple programs that may help with your
getting index-able arrays from and into PNG images.
These may require an upgraded version of PIL; the examples here work with version 1.1.6. You can learn the version by doing this in python:
where "1.1.6" is the output of the second statement.>>> import Image >>> Image.VERSION '1.1.6'
interpolating between the second and third control point would involve x0=32767 to x1=43690, and (for the green channel) y0=0 to y1=255. The red and blue channels would be interpolated similarly.0 0 0 0 32767 255 0 0 43690 255 255 0 65535 255 255 255