CS3022H –Tutorial 4

$30.00

Category: You will Instantly receive a download link for .zip solution file upon Payment || To Order Original Work Click Custom Order?

Description

5/5 - (5 votes)

Write an Image class which supports simple operations on pairs of PGM images.
An image is a 2D array of numbers, each of which corresponds to the intensity of
a pixel on the screen. So, essentially you will be writing a program that will
manipulate 2D arrays of numbers. For any pair of “source” images, your program
must support the following image operations, which generate a new output
image:
1. Add I1 I2 : add the pixel values of I1 to I2 (i.e. at every corresponding 2D
position you add the two values)
2. Subtract I1 I2 : subtract pixel values of I2 from I1
3. Invert I1 : replace each pixel value p with (255 – p) NOTE: ONE image
only
4. Mask I1 I2 : given I1 and an image I2, copy across values from I1 where I2
has a value of 255. All other output values are set to 0. An example of
‘masking’ is shown above.
5. Threshold I1 f : for all pixels in I1 > f, set the result to the integer 255,
otherwise set the value to 0. You can build a mask using this function.
The program will be driven from the command line, so you will need to use argv
and argc in the main() function to process the parameters the user enters when
running the program. The options are of the form (I1 and I2 represent image file
names):
 -a I1 I2 (add I1 and I2)
 -s I1 I2 (subtract I2 from I1)
Input Mask Output
 -i I1 (invert I1)
 -l I1 I2 (mask I1 with I2)
 -t I1 f (threshold I1 with integer value f)
The command line form will thus be
imageops