#include "pvm_imagelib.h"
#include "pvm3.h"


void main(int argc , char *argv[]){

  char imageName[255];
  char type[255];
  long offset,imageSize,width,amountToRead,amountToProcess;
  unsigned char * data;
  int thresh;
#ifdef debug
  printf("started\n\n");
#endif
  pvm_recv(-1,-1);
  
  pvm_upkstr(imageName);
  pvm_upkstr(type);
  pvm_upklong(&offset,1,1);
  pvm_upklong(&width,1,1);
  pvm_upklong(&amountToRead,1,1);
  pvm_upkint(&thresh,1,1);
  data = readData(imageName,amountToRead,offset);
  if (strcmp(type,"grey")==0){
    data = sobel(data,amountToRead,width,thresh);
    printf("type = %s\n",type);
  }
  else
    data = color_sobel(data,amountToRead,width,thresh);
  writeData(data,amountToRead,offset);

  pvm_initsend(PvmDataDefault);
  pvm_pklong(&offset,1,1);
  pvm_send(pvm_parent(),1);
  pvm_exit();
}

