Answered step by step
Verified Expert Solution
Question
1 Approved Answer
You will not only learn to program C + + in this class, we will also show you some other things. One of these things
You will not only learn to program C in this class, we will also show you some other things. One of these things is the plain PGM image file format.
You will be working with this image format in this class.
Many applications have PGM support builtin Unfortunately, Windows does not currently come with an app which can display PGM images. MacOS
Sierras Preview app can display PGMs On Windows, you can download IrfanView if you need a viewer. It is highly recommended that you have a
program to view these files. For Macs, MacOS Sierra has finally added support for PGM images to the allpurpose viewer Preview, but you can also
use ToyViewer available free on the App store which I find convenient for image viewing.
For Irfanview, uncheck Use Resample for fitting and Use Resample for zooming under View Display Options Otherwise by default
Irfanview blurs images when you zoom them. Thats great for general image viewing, but awkward for programmers trying to figure out what their
program just wrote out to a PGM file.
The complete specification for the PGM format can be found on the netpbm website look for plain PGM or in Wikipedia: Portable Pixmap. A plain
PGM file is just a simple text file that follows the following standard:
The first element in the file is the text P
The second and third elements specify the size of the image width and height, in number of pixels
The fourth element specifies the maximum gray value maxval This is the largest number that can appear in the actual image data
After that, each line consists of a line of image data, given in grayvalues where is black and whatever the maxval is is white.
These are grayscale images there is a P color version called PPM see the netpgm site above for more information.
given all this, here's an example:
P
You can download the image: mbpgm
All the fields header & pixel values are actually freeformat, so youll commonly see all the header information on the same line:
P
You can also read and display PGM images in matlab with a simple script like this:
I imreadmbpgm
imshowI
As an image, mbpgm looks like this if you zoom it about xIts Max Berger's initials...
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started