title: Convert jpg image in ppm P3 ASCII format using Opencv
body: <p>Using opencv imwrite function I managed to convert jpg image in ppm P6 format.</p>
  
  <pre><code>Mat image = imread(picPath);
  
  vector&lt;int&gt; compression_params;
  compression_params.push_back(CV_IMWRITE_PXM_BINARY);
  compression_params.push_back(1);
  
  imwrite("bez.ppm", image, compression_params);
  </code></pre>
  
  <p>Problem is that I actually have to convert jpg image in ppm P3 ASCII format.
  Does anyone know how to do it? 
  Thanks!</p>
  
  <p>EDIT:</p>
  
  <p>In the project I have the following piece of code where I check the maximum value of pixels: </p>
  
  <pre><code>int maxVal; 
  fscanf(in, "%d", &amp;maxVal); 
  if (maxVal != 255)
  { 
      printf("Input file error: Not a Netpbm color image with 256 levels\n");
      exit(0); 
  } 
  </code></pre>
  
  <p>When I set parameter 0 then I get: Not a Netpbm color image with 256 levels! </p>
  
  <p>When I do the conversion from jpg to ppm p3 with irfanview program works.</p>