CSJ2K.j2k.image.ImgDataJoiner.ImgDataJoiner C# (CSharp) Метод

ImgDataJoiner() публичный Метод

Class constructor. Each input BlkImgDataSrc and its component index must appear in the order wanted for the output components.
Example: Reading R,G,B components from 3 PGM files.
BlkImgDataSrc[] idList =
{
new ImgReaderPGM(new BEBufferedRandomAccessFile("R.pgm", "r")),
new ImgReaderPGM(new BEBufferedRandomAccessFile("G.pgm", "r")),
new ImgReaderPGM(new BEBufferedRandomAccessFile("B.pgm", "r"))
};
int[] compIdx = {0,0,0};
ImgDataJoiner idj = new ImgDataJoiner(idList, compIdx);

Of course, the 2 arrays must have the same length (This length is the number of output components). The image width and height are definded to be the maximum values of all the input ImgData.

public ImgDataJoiner ( IList imD, IList cIdx ) : System.Collections.Generic
imD IList The list of input BlkImgDataSrc in an array. /// ///
cIdx IList The component index associated with each ImgData. /// ///
Результат System.Collections.Generic
        public ImgDataJoiner(IList<ImgReader> imD, IList<int> cIdx)
        {
            int i;
            int maxW, maxH;

            // Initializes
            imageData = imD;
            compIdx = cIdx;
            if (imageData.Count != compIdx.Count)
                throw new System.ArgumentException("imD and cIdx must have the" + " same length");

            nc = imD.Count;

            subsX = new int[nc];
            subsY = new int[nc];

            // Check that no source is tiled and that the image origin is at the
            // canvas origin.
            for (i = 0; i < nc; i++)
            {
                if (imD[i].getNumTiles() != 1 || imD[i].getCompULX(cIdx[i]) != 0 || imD[i].getCompULY(cIdx[i]) != 0)
                {
                    throw new System.ArgumentException("All input components must, " + "not use tiles and must " + "have " + "the origin at the canvas " + "origin");
                }
            }

            // Guess component subsampling factors based on the fact that the
            // ceil() operation relates the reference grid size to the component's
            // size, through the subsampling factor.

            // Mhhh, difficult problem. For now just assume that one of the
            // subsampling factors is always 1 and that the component width is
            // always larger than its subsampling factor, which covers most of the
            // cases. We check the correctness of the solution once found to chek
            // out hypothesis.

            // Look for max width and height.
            maxW = 0;
            maxH = 0;
            for (i = 0; i < nc; i++)
            {
                if (imD[i].getCompImgWidth(cIdx[i]) > maxW)
                    maxW = imD[i].getCompImgWidth(cIdx[i]);
                if (imD[i].getCompImgHeight(cIdx[i]) > maxH)
                    maxH = imD[i].getCompImgHeight(cIdx[i]);
            }
            // Set the image width and height as the maximum ones
            w = maxW;
            h = maxH;

            // Now get the sumsampling factors and check the subsampling factors,
            // just to see if above hypothesis were correct.
            for (i = 0; i < nc; i++)
            {
                // This calculation only holds if the subsampling factor is less
                // than the component width
                subsX[i] = (maxW + imD[i].getCompImgWidth(cIdx[i]) - 1) / imD[i].getCompImgWidth(cIdx[i]);
                subsY[i] = (maxH + imD[i].getCompImgHeight(cIdx[i]) - 1) / imD[i].getCompImgHeight(cIdx[i]);
                if ((maxW + subsX[i] - 1) / subsX[i] != imD[i].getCompImgWidth(cIdx[i]) || (maxH + subsY[i] - 1) / subsY[i] != imD[i].getCompImgHeight(cIdx[i]))
                {
                    throw new System.InvalidOperationException("Can not compute component subsampling " + "factors: strange subsampling.");
                }
            }
        }