title: How can I generalize the quantization matrix in JPEG compression?
body: <p>I'm working on JPEG image compression where I investigated the use of the quantization matrix which is usually given in literature, but I want to write program so that when I vary the matrix, the number of bits per pixel to represent should also vary  so that i can plot the graph for bits per pixel versus PSNR.</p>
  
  <p>The base quantization matrix that I have seen is defined as the following:</p>
  
  <pre><code>qm = [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]; 
  </code></pre>
  
  <p>How can I generalize creating the quantization matrix?</p>