I don't get it. How is his code treating pixels differently according to intensity?
If a pixel's value is '7' and in the redacted zone, the program will iterate over the single character and output '0'. If the pixel's value is actually '174', the program will iterate over all three characters, outputting '000'. Any normal PPM image viewer will display these identically, but high contrast areas like text will be recoverable.