I have a program I'm working on for class (CSC 150). I have to read a pgm file into an array, copy it to a second array, manipulate the image and then output to a second file.
I'm having a heck of a time figuring out how to do the actual manipulation. The simplest of these is as follows:
The emboss operation takes the pixel at the lower right and subtracts the center pixel, then adds the value 8. If the result is < 0 the final result is 0. If the result is > 15, the result is 15. You must do this for every pixel that does not lie on the border.
i.e. -3 goes to 0, 18 goes to 15
Original data O (this is in a grid) Modified data M
rows a b c
d e f e
g h i
M(e) = O( i ) – O( e ) + 8
I have no idea how to express this. It seems I would have to start with the bottom right number in the file and work my way up (somehow). Any help would be very much appreciated!