Hi,
Proposal: Because of my graphics and algorithm background along with coding experience with tech companies, the problem seems simple. I will write the code as mentioned, as well as just as an extra, will give you a simple exe if you need to view ppm input and output files as bitmap(jpg/bmp). I am putting 1 day as deadline though if not urgent I would prefer taking half day more in case of any issues and to ensure quality. Please let me know if you want this earlier and I will do that.
About me: Masters in computer engineering (image processing, graphics) from a premier institute. Worked as software engineer in tech giants. Have published research paper in image processing and created a 1 Million+ download mobile application. Starting freelancing as side work and learning experience while I am working on my own products. PM me to get details.