title: Jpeg compression artefact (green pixel)
body: <p>I'm programming an artisanal jpeg algorithm. However, the quantization step seems to be problematic :
  Here is the picture i'm trying to encode : <a href="https://i.stack.imgur.com/MnHVb.png" rel="nofollow noreferrer">Lena.png</a></p>
  
  <p>And here is the result just after the quantization step (+decoding but without the huffman encoding stuff) : <a href="https://i.stack.imgur.com/03ZVO.png" rel="nofollow noreferrer">post quantization result</a></p>
  
  <p>Now my code for this step : </p>
  
  <pre><code>def quantification(transformee) :
  matrice=np.array([(16 , 11 , 10 , 16 , 24 , 40 , 51 , 61 ),(12 , 12 , 14 , 19 , 26 , 58 , 60 , 55 ),(14 , 13 , 16 , 24 , 40 , 57 , 69 , 56 ),(14 , 17 , 22 , 29 , 51 , 87 , 80 , 62 ),(18 , 22 , 37 , 56 , 68 , 109 , 103 , 77 ),(24 , 35 , 55 , 64 , 81 , 104 , 113 , 92 ),(49 , 64 , 78 , 87 , 103 , 121 , 120 , 101 ),( 72 , 92 , 95 , 98 , 112 , 100 , 103 , 99)],dtype=float)
  quanti=[]
  for i in transformee :
      k=i/matrice
      quanti+=[np.around(k)]
  return quanti
  
  def dequantification(quanti) :
  matrice=np.array([(16 , 11 , 10 , 16 , 24 , 40 , 51 , 61 ),(12 , 12 , 14 , 19 , 26 , 58 , 60 , 55 ),(14 , 13 , 16 , 24 , 40 , 57 , 69 , 56 ),(14 , 17 , 22 , 29 , 51 , 87 , 80 , 62 ),(18 , 22 , 37 , 56 , 68 , 109 , 103 , 77 ),(24 , 35 , 55 , 64 , 81 , 104 , 113 , 92 ),(49 , 64 , 78 , 87 , 103 , 121 , 120 , 101 ),( 72 , 92 , 95 , 98 , 112 , 100 , 103 , 99)],dtype=float)
  retour_transformee=[]
  for k in quanti :
      temp=np.zeros((8,8),dtype=float)
      for i in range(8) :
          for j in range(8) :
              temp[i,j]=matrice[i,j]*k[i,j]
      retour_transformee.append(temp)
  return retour_transformee
  </code></pre>
  
  <p>transformee is a list of 8*8 matrix (DCT is already used).
  The quantization matrix is the one given in wikipedia (JPEG)</p>
  
  <p>Sorry for the french part in the algorithm </p>