// imageproc_02.cpp - image processing + patterns
#include <iostream>
#include <fstream>

unsigned char processPixel(unsigned char pixVal);

int main() {
  using namespace std;
  
  unsigned char pix;
  unsigned char newpix;
  
  // using dimensions for looping
  const int WIDTH = 100;
  const int HEIGHT = 100;

  char outFileName[20];
  
  // setting up input and output files
  ifstream inFile;
  inFile.open("face.raw");
  ofstream outFile;
 
  cout << "Enter a output file: ";
  cin >> outFileName;
  outFile.open(outFileName);

  for(int i=0;i<WIDTH*HEIGHT;i++) {
    inFile >> pix;

    if (i%2 == 0) newpix = processPixel(pix);
    else newpix = 255;

    outFile << newpix;
 
  }
    
  inFile.close();
  outFile.close();
}

unsigned char processPixel(unsigned char pixVal) {

  if (pixVal > 127) return 255;
  else return 0;

}

