Example #1
0
        ///<summary>
        ///Split current Image into an array of gray scale images where each element
        ///in the array represent a single color channel of the original image
        ///</summary>
        ///<param name="gpuMats">
        ///An array of single channel GpuMat where each item
        ///in the array represent a single channel of the original GpuMat
        ///</param>
        /// <param name="stream">Use a Stream to call the function asynchronously (non-blocking) or null to call the function synchronously (blocking).</param>
        private void SplitInto(GpuMat[] gpuMats, Stream stream)
        {
            Debug.Assert(NumberOfChannels == gpuMats.Length, "Number of channels does not agrees with the length of gpuMats");

            if (NumberOfChannels == 1)
            {
                //If single channel, return a copy
                CopyTo(gpuMats[0], null, stream);
            }
            else
            {
                //handle multiple channels

                Size size = Size;

                for (int i = 0; i < gpuMats.Length; i++)
                {
                    gpuMats[i].Create(size.Height, size.Width, Depth, 1);
                }

                using (VectorOfGpuMat vm = new VectorOfGpuMat(gpuMats))
                    CudaInvoke.Split(this, vm, stream);
            }
        }