CSJ2K.j2k.wavelet.analysis.SubbandAn.assignL2Norm C# (CSharp) Method

assignL2Norm() private method

Assigns the given L2-norm to the first leaf that does not have an L2-norm value yet (i.e. l2norm is negative). The search is done recursively and in the same order as that of the calcBasisWaveForms() method, so that this method is used to assigne the l2norm of the previously computed waveforms.

This method can not be called on an element that ahs a non-negative value in l2Norm, since that means that we are done.

private assignL2Norm ( float l2n ) : void
l2n float The L2-norm to assign. /// ///
return void
        private void assignL2Norm(float l2n)
        {
            if (l2Norm < 0)
            {
                // We are not finished with this element yet
                if (isNode)
                {
                    // We are on a node => search on childs
                    if (subb_LL.l2Norm < 0f)
                    {
                        subb_LL.assignL2Norm(l2n);
                    }
                    else if (subb_HL.l2Norm < 0f)
                    {
                        subb_HL.assignL2Norm(l2n);
                    }
                    else if (subb_LH.l2Norm < 0f)
                    {
                        subb_LH.assignL2Norm(l2n);
                    }
                    else if (subb_HH.l2Norm < 0f)
                    {
                        subb_HH.assignL2Norm(l2n);
                        // If child now is done, we are done
                        if (subb_HH.l2Norm >= 0f)
                        {
                            l2Norm = 0f; // We are on a node, any non-neg value OK
                        }
                    }
                    else
                    {
                        // There is an error! If all childs have non-negative
                        // l2norm, then this node should have non-negative l2norm
                        throw new System.InvalidOperationException("You have found a bug in JJ2000!");
                    }
                }
                else
                {
                    // This is a leaf, assign the L2-norm
                    l2Norm = l2n;
                }
            }
            else
            {
                // This is an error! The assignL2Norm() method is never called on
                // an element with non-negative l2norm
                throw new System.InvalidOperationException("You have found a bug in JJ2000!");
            }
        }

Usage Example

Example #1
0
 /// <summary> Assigns the given L2-norm to the first leaf that does not have an
 /// L2-norm value yet (i.e. l2norm is negative). The search is done
 /// recursively and in the same order as that of the calcBasisWaveForms()
 /// method, so that this method is used to assigne the l2norm of the
 /// previously computed waveforms.
 ///
 /// <p>This method can not be called on an element that ahs a non-negative
 /// value in l2Norm, since that means that we are done.</p>
 ///
 /// </summary>
 /// <param name="l2n">The L2-norm to assign.
 ///
 /// </param>
 private void  assignL2Norm(float l2n)
 {
     if (l2Norm < 0)
     {
         // We are not finished with this element yet
         if (isNode)
         {
             // We are on a node => search on childs
             if (subb_LL.l2Norm < 0f)
             {
                 subb_LL.assignL2Norm(l2n);
             }
             else if (subb_HL.l2Norm < 0f)
             {
                 subb_HL.assignL2Norm(l2n);
             }
             else if (subb_LH.l2Norm < 0f)
             {
                 subb_LH.assignL2Norm(l2n);
             }
             else if (subb_HH.l2Norm < 0f)
             {
                 subb_HH.assignL2Norm(l2n);
                 // If child now is done, we are done
                 if (subb_HH.l2Norm >= 0f)
                 {
                     l2Norm = 0f;                             // We are on a node, any non-neg value OK
                 }
             }
             else
             {
                 // There is an error! If all childs have non-negative
                 // l2norm, then this node should have non-negative l2norm
                 throw new System.ApplicationException("You have found a bug in JJ2000!");
             }
         }
         else
         {
             // This is a leaf, assign the L2-norm
             l2Norm = l2n;
         }
     }
     else
     {
         // This is an error! The assignL2Norm() method is never called on
         // an element with non-negative l2norm
         throw new System.ApplicationException("You have found a bug in JJ2000!");
     }
 }