internal unsafe static void SetValue(IImage img, Array arr)
        {
            IImage[] channels = GetChannels(arr);

            if (img.ColorInfo.NumberOfChannels != channels.Length)
            {
                throw new Exception("Number of channels in the image must be equal to array depth (0th dimension)");
            }

            ChannelMerger.MergeChannels(channels, img);
        }
Example #2
0
 /// <summary>
 /// Gets or sets image channel.
 /// Channel size must be the same as image size.
 /// </summary>
 /// <param name="channelIdx">Index of an channel to get or replace.</param>
 /// <returns>Image channel.</returns>
 IImage IImage.this[int channelIdx]
 {
     get
     {
         return(ChannelSplitter.SplitChannels(this, channelIdx)[0]);
     }
     set
     {
         ChannelMerger.MergeChannels(new IImage[] { value }, this, channelIdx);
     }
 }
Example #3
0
        /// <summary>
        /// Construct an image from channels.
        /// </summary>
        /// <param name="channels">Channels. The number of channels must be the same as number of channels specified by this color type.</param>
        public Image(Image <Gray, TDepth>[] channels)
            : this()
        {
            if (ColorInfo.NumberOfChannels != channels.Length)
            {
                throw new Exception("Number of channels must be the same as number of channels specified by this color type!");
            }

            int width  = channels[0].Width;
            int height = channels[0].Height;

            Image.Initialize(this, width, height);
            ChannelMerger.MergeChannels <TColor, TDepth>(channels, this);
        }