Пример #1
0
        /// <summary>
        /// Back-projects (creates probability map) from histogram values.
        /// </summary>
        /// <param name="srcs">Image channels.</param>
        /// <returns>Back-projection image (probability image) </returns>
        public Gray <byte>[,] BackProject(Gray <byte>[][,] srcs)
        {
            var destImg = srcs.First().CopyBlank();

            using (var uDestImg = destImg.Lock())
            {
                var uChannels = srcs.Select(x => x.Lock()).ToArray();
                backProjectByte(this, uChannels, uDestImg);
                uChannels.ForEach(x => x.Dispose());
            }

            return(destImg);
        }
        /// <summary>
        /// Back-projects (creates probability map) from histogram values.
        /// </summary>
        /// <param name="srcs">Image channels.</param>
        /// <returns>Back-projection image (probability image) </returns>
        public Gray<byte>[,] BackProject(Gray<byte>[][,] srcs)
        {
            var destImg = srcs.First().CopyBlank();

            using (var uDestImg = destImg.Lock())
            {
                var uChannels = srcs.Select(x => x.Lock()).ToArray();
                backProjectByte(this, uChannels, uDestImg);
                uChannels.ForEach(x => x.Dispose());
            }

            return destImg;
        }
        /// <summary>
        /// Calculates histogram.
        /// </summary>
        /// <param name="channels">Image channels.</param>
        /// <param name="accumulate">Accumulate or erase histogram before.</param>
        /// <param name="mask">Mask for image color locations.</param>
        /// <param name="maskOffset">The location offset for the mask. The mask area will be [offsetX, offsetY, channelWidth, channelHeight].</param>
        public void Calculate(Gray<byte>[][,] channels, bool accumulate, Gray<byte>[,] mask, Point maskOffset)
        {
            if (!accumulate)
                Array.Clear(histogram, 0, this.NumberOfElements);

            if (mask == null)
            {
                mask = new Gray<byte>[channels[0].Width(), channels[0].Height()];
                mask.SetValue<Gray<byte>>(Byte.MaxValue);
            }

            var maskArea = new Rectangle(maskOffset, channels.First().Size());
            using (var uMask = mask.Lock(maskArea))
            {
                var uChannels = channels.Select(x => x.Lock()).ToArray();
                calculateHistByte(this, uChannels, uMask);
                uChannels.ForEach(x => x.Dispose());
            }
        }
Пример #4
0
        /// <summary>
        /// Calculates histogram.
        /// </summary>
        /// <param name="channels">Image channels.</param>
        /// <param name="accumulate">Accumulate or erase histogram before.</param>
        /// <param name="mask">Mask for image color locations.</param>
        /// <param name="maskOffset">The location offset for the mask. The mask area will be [offsetX, offsetY, channelWidth, channelHeight].</param>
        public void Calculate(Gray <byte>[][,] channels, bool accumulate, Gray <byte>[,] mask, Point maskOffset)
        {
            if (!accumulate)
            {
                Array.Clear(histogram, 0, this.NumberOfElements);
            }

            if (mask == null)
            {
                mask = new Gray <byte> [channels[0].Width(), channels[0].Height()];
                mask.SetValue <Gray <byte> >(Byte.MaxValue);
            }

            var maskArea = new Rectangle(maskOffset, channels.First().Size());

            using (var uMask = mask.Lock(maskArea))
            {
                var uChannels = channels.Select(x => x.Lock()).ToArray();
                calculateHistByte(this, uChannels, uMask);
                uChannels.ForEach(x => x.Dispose());
            }
        }