CSJ2K.j2k.wavelet.Subband.getSubbandByIdx C# (CSharp) Method

getSubbandByIdx() public method

Returns a subband element in the tree, given its resolution level and subband index. This method searches through the tree.
public getSubbandByIdx ( int rl, int sbi ) : Subband
rl int The resolution level. /// ///
sbi int The subband index, within the resolution level. /// ///
return Subband
        public virtual Subband getSubbandByIdx(int rl, int sbi)
        {
            Subband sb = this;

            // Find the root subband for the resolution level
            if (rl > sb.resLvl || rl < 0)
            {
                throw new System.ArgumentException("Resolution level index " + "out of range");
            }

            // Returns directly if it is itself
            if (rl == sb.resLvl && sbi == sb.sbandIdx)
                return sb;

            if (sb.sbandIdx != 0)
                sb = sb.Parent;

            while (sb.resLvl > rl)
                sb = sb.LL;
            while (sb.resLvl < rl)
                sb = sb.Parent;

            switch (sbi)
            {

                case 0:
                default:
                    return sb;

                case 1:
                    return sb.HL;

                case 2:
                    return sb.LH;

                case 3:
                    return sb.HH;
                }
        }