title: File editor- counturing ppm file
body: <p>I'm making an image editor for pgm and ppm files and i have problem with one function. The contouring which should look like <a href="https://imgur.com/a/sRvvqc9" rel="nofollow noreferrer">this</a>. This was made by the function: convert -convolve 0,0,0,0,-2,1,0,1,0 picture.ppm pictureRes.ppm in terminal. Unfortunately my program gives me <a href="https://imgur.com/a/OnOJrt0" rel="nofollow noreferrer">this</a></p>
  
  <pre><code>void konturowanie(t_obraz *obraz,int odczytano) // odczytano tells us with what sort of file we are dealing ppm=3 pgm else
  {
    if (odczytano == 3)
    {
  for (int j = 0; j &lt; 3*obraz-&gt;wymx; j++)
  {
     for (int i = 0; i &lt; obraz-&gt;wymy; i++)
    {
     obraz-&gt;piksele[j * (obraz-&gt;wymy) + i] = (abs(obraz-&gt;piksele[(j+1) * (obraz-&gt;wymy) + i] - obraz-&gt;piksele[j * (obraz-&gt;wymy) + i])) + (abs(obraz-&gt;piksele[j * (obraz-&gt;wymy) + i+1] - obraz-&gt;piksele[j * (obraz-&gt;wymy) + i]));
     }
  }
  }
  else
  {
    for (int i = 0; i &lt; obraz-&gt;wymx; i++)
    {
      for (int j = 0; j &lt; obraz-&gt;wymy; j++)
       {
         obraz-&gt;piksele[j * (obraz-&gt;wymx) + i] = (abs(obraz-&gt;piksele[(j+1) * (obraz-&gt;wymx) + i] - obraz-&gt;piksele[j * (obraz-&gt;wymx) + i])) + (abs(obraz-&gt;piksele[j * (obraz-&gt;wymx) + i+1] - obraz-&gt;piksele[j * (obraz-&gt;wymx) + i]));
     } 
    }
   }
  }
  </code></pre>
  
  <p>`</p>
  
  <pre><code>typedef struct //and struck in which this is stored
  {
   int wymx, wymy, szarosci;
   int *piksele; 
   } t_obraz;
  </code></pre>
  
  <p>The code is working fine for pgm files but it doesn't for ppm,I cant see any mistakes and im stuck, thanks for help in advance</p>