title: Matrix encoding implementation in the F5 steganography algorithm is unclear
body: <p>I need to implement my own F5 algorithm. I have read the F5 documentation and the paper can be found <a href="https://f5-steganography.googlecode.com/svn/tags/release-0.3/F5%20Steganography.pdf" rel="nofollow">here</a>.</p>
  
  <p>In the section <em>6.2 Matrix Encoding</em> of the paper, equations 16-18 define the change density, <code>D(k)</code>, the embedding rate, <code>R(k)</code> and the efficiency rate, <code>W(k)</code>, as follows:</p>
  
  <pre><code>D(k) = 1 / (n + 1) = 1 / 2**k
  
  R(k) = k / n = k / (2**k - 1)
  
  W(k) = R(k) / D(k) = k * 2**k / (2**k - 1)
  </code></pre>
  
  <p>Where <code>n</code> is the number of modifiable places in a code word and <code>k</code> the number of embedding bits. <code>W(k)</code> indicats the average number of bits we can embed per change.</p>
  
  <p>In the source code we find the number of bits as stated below. Can someome please explain why <code>usable</code> and <code>changed</code> are calculated this way? I simply don't understand the logic.</p>
  
  <pre><code>    int _changed = 0;
      int _expected = 0;
      int _one = 0;
      int _large = 0;
      int _zero = 0;
      for (i = 0; i &lt; coeffCount; i++) {
          if (i % 64 == 0) {
              continue;
          }
          if (coeff[i] == 1) {
              _one++;
          }
          if (coeff[i] == -1) {
              _one++;
          }
          if (coeff[i] == 0) {
              _zero++;
          }
      }
      _large = coeffCount - _zero - _one - coeffCount / 64;
      _expected = _large + (int) (0.49 * _one);
  for (i = 1; i &lt; 8; i++) {
      int usable, changed, n;
      n = (1 &lt;&lt; i) - 1;
      usable = _expected * i / n - _expected * i / n % n;
      changed = coeffCount - _zero - coeffCount / 64;
      changed = changed * i / n - changed * i / n % n;
      changed = n * changed / (n + 1) / i;
      //
      changed = _large - _large % (n + 1);
      changed = (changed + _one + _one / 2 - _one / (n + 1)) / (n + 1);
      usable /= 8;
      if (usable == 0) {
          break;
      }
      if (i == 1) {
          System.out.print("default");
      } else {
          System.out.print("(1, " + n + ", " + i + ")");
      }
      System.out.println(" code: " + usable + " bytes (efficiency: " + usable * 8 / changed + "." + usable * 8
              / changed % 10 + " bits per change)");
  }
  </code></pre>
  
  <p>coeff is an array that holds the DCT coefficients,coeffCount is the number of DCT coefficients,_large is the teoretical number of bits from the image that can be encoded and expected is the expected capacity of the image(with shrinkage).I don't understand what is the logic behind usable and changed variables </p>