Answered step by step
Verified Expert Solution
Link Copied!

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 built-in. 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 all-purpose 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 P2
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 0 is black and whatever the maxval is is white.
[1]
(These are grayscale images there is a "P5" color version called PPM see the netpgm site above for more information.)
given all this, here's an example:
P2
147
15
00000000000000
0100001000151515000
01010010100015001500
01001001000151515000
010000100015001500
0100001040151515040
00000000000000
You can download the image: mb.pgm
All the fields (header & pixel values) are actually free-format, so youll commonly see all the header information on the same line:
P214715
0000000...
You can also read and display PGM images in matlab with a simple script like this:
I = imread('mb.pgm')
imshow(I)
As an image, mb.pgm looks like this (if you zoom it about 40x).(It's Max Berger's initials...)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Expert Systems Applications 24th International Conference Dexa 2013 Prague Czech Republic August 2013 Proceedings Part 2 Lncs 8056

Authors: Hendrik Decker ,Lenka Lhotska ,Sebastian Link ,Josef Basl ,A Min Tjoa

2013th Edition

3642401724, 978-3642401725

Students also viewed these Databases questions

Question

Evaluate the importance of diversity in the workforce.

Answered: 1 week ago

Question

Identify the legal standards of the recruitment process.

Answered: 1 week ago