p2-cv

Working with PPM Files

Viewing

If you’re logged into a CAEN computer or working remotely with VNC, you can just double click on PPM files and they will open in Image Viewer. The GIMP is also available on CAEN computers and displays the images more clearly than Image Viewer.

If you’re on Windows, a number of programs can view PPM files, but two options are the GIMP (https://www.gimp.org/) and IrfanView (http://download.cnet.com/IrfanView/).

If you’re on a Mac, you can use ToyViewer (https://itunes.apple.com/us/app/toyviewer/id414298354).

Creating

We’ve provided you some PPM files to work with, but here’s how you can create more. If you’re on CAEN or Ubuntu Linux, you can use the ImageMagick convert tool to convert files in other image formats to PPM. It might need to be installed at the command line via:

$ sudo apt install imagemagick

Use it like this:

$ convert imageFile.png -compress none imageFile.ppm

You can also use convert in the other direction:

$ convert imageFile.ppm imageFile.png

If you’re on another distribution of Linux, Windows, or a Mac, you may not have the ImageMagick suite already, but you should be able to install it. The process seems more or less complicated depending on the platform, but if you would like to try, visit http://www.imagemagick.org/.

Otherwise, several programs exist that are able to save images into PPM format. One that works across all platforms is the GIMP. You can find it online at https://www.gimp.org/. Note that the GIMP may include comments in saved PPM files, which must be removed.

Comments

The images we provide with the project don’t have any comments, but some programs that generate PPM images may include comments (e.g. the GIMP), which are not supported by the Image_init function (i.e. you don’t have to account for them in your implementation). If you’re on CAEN or Ubuntu Linux, you can use the sed tool to remove all comments from a PPM file with a command like this:

$ sed -e 's/#.*$//' -e '/^\s*$/d' -i imageFile.ppm