CSJ2K.j2k.wavelet.synthesis.InvWTFull.wavelet2DReconstruction C# (CSharp) Метод

wavelet2DReconstruction() приватный Метод

Performs the 2D inverse wavelet transform on a subband of the image, on the specified component. This method will successively perform 1D filtering steps on all columns and then all lines of the subband.
private wavelet2DReconstruction ( CSJ2K.j2k.image.DataBlk db, CSJ2K.j2k.wavelet.synthesis.SubbandSyn sb, int c ) : void
db CSJ2K.j2k.image.DataBlk the buffer for the image/wavelet data. /// ///
sb CSJ2K.j2k.wavelet.synthesis.SubbandSyn The subband to reconstruct. /// ///
c int The index of the component to reconstruct /// ///
Результат void
        private void wavelet2DReconstruction(DataBlk db, SubbandSyn sb, int c)
        {
            System.Object data;
            System.Object buf;
            int ulx, uly, w, h;
            int i, j, k;
            int offset;

            // If subband is empty (i.e. zero size) nothing to do
            if (sb.w == 0 || sb.h == 0)
            {
                return ;
            }

            data = db.Data;

            ulx = sb.ulx;
            uly = sb.uly;
            w = sb.w;
            h = sb.h;

            buf = null; // To keep compiler happy

            switch (sb.HorWFilter.DataType)
            {

                case DataBlk.TYPE_INT:
                    buf = new int[(w >= h)?w:h];
                    break;

                case DataBlk.TYPE_FLOAT:
                    buf = new float[(w >= h)?w:h];
                    break;
                }

            //Perform the horizontal reconstruction
            offset = (uly - db.uly) * db.w + ulx - db.ulx;
            if (sb.ulcx % 2 == 0)
            {
                // start index is even => use LPF
                for (i = 0; i < h; i++, offset += db.w)
                {
                    // CONVERSION PROBLEM?
                    Array.Copy((System.Array)data, offset, (System.Array)buf, 0, w);
                    sb.hFilter.synthetize_lpf(buf, 0, (w + 1) / 2, 1, buf, (w + 1) / 2, w / 2, 1, data, offset, 1);
                }
            }
            else
            {
                // start index is odd => use HPF
                for (i = 0; i < h; i++, offset += db.w)
                {
                    // CONVERSION PROBLEM?
                    Array.Copy((System.Array)data, offset, (System.Array)buf, 0, w);
                    sb.hFilter.synthetize_hpf(buf, 0, w / 2, 1, buf, w / 2, (w + 1) / 2, 1, data, offset, 1);
                }
            }

            //Perform the vertical reconstruction
            offset = (uly - db.uly) * db.w + ulx - db.ulx;
            switch (sb.VerWFilter.DataType)
            {

                case DataBlk.TYPE_INT:
                    int[] data_int, buf_int;
                    data_int = (int[]) data;
                    buf_int = (int[]) buf;
                    if (sb.ulcy % 2 == 0)
                    {
                        // start index is even => use LPF
                        for (j = 0; j < w; j++, offset++)
                        {
                            for (i = h - 1, k = offset + i * db.w; i >= 0; i--, k -= db.w)
                                buf_int[i] = data_int[k];
                            sb.vFilter.synthetize_lpf(buf, 0, (h + 1) / 2, 1, buf, (h + 1) / 2, h / 2, 1, data, offset, db.w);
                        }
                    }
                    else
                    {
                        // start index is odd => use HPF
                        for (j = 0; j < w; j++, offset++)
                        {
                            for (i = h - 1, k = offset + i * db.w; i >= 0; i--, k -= db.w)
                                buf_int[i] = data_int[k];
                            sb.vFilter.synthetize_hpf(buf, 0, h / 2, 1, buf, h / 2, (h + 1) / 2, 1, data, offset, db.w);
                        }
                    }
                    break;

                case DataBlk.TYPE_FLOAT:
                    float[] data_float, buf_float;
                    data_float = (float[]) data;
                    buf_float = (float[]) buf;
                    if (sb.ulcy % 2 == 0)
                    {
                        // start index is even => use LPF
                        for (j = 0; j < w; j++, offset++)
                        {
                            for (i = h - 1, k = offset + i * db.w; i >= 0; i--, k -= db.w)
                                buf_float[i] = data_float[k];
                            sb.vFilter.synthetize_lpf(buf, 0, (h + 1) / 2, 1, buf, (h + 1) / 2, h / 2, 1, data, offset, db.w);
                        }
                    }
                    else
                    {
                        // start index is odd => use HPF
                        for (j = 0; j < w; j++, offset++)
                        {
                            for (i = h - 1, k = offset + i * db.w; i >= 0; i--, k -= db.w)
                                buf_float[i] = data_float[k];
                            sb.vFilter.synthetize_hpf(buf, 0, h / 2, 1, buf, h / 2, (h + 1) / 2, 1, data, offset, db.w);
                        }
                    }
                    break;
                }
        }