Exemplo n.º 1
0
        /// <summary>
        /// Determines whether the specified image statistics is equal to the current <see cref="Statistics"/>.
        /// </summary>
        /// <param name="other">The image statistics to compare this <see cref="Statistics"/> with.</param>
        /// <returns>True when the specified image statistics is equal to the current <see cref="Statistics"/>.</returns>
        public bool Equals(IStatistics other)
        {
            if (other is null)
            {
                return(false);
            }

            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            var otherChannels = new List <PixelChannel>(other.Channels);

            if (_channels.Count != otherChannels.Count)
            {
                return(false);
            }

            foreach (PixelChannel channel in _channels.Keys)
            {
                if (!otherChannels.Contains(channel))
                {
                    return(false);
                }

                var otherChannel = other.GetChannel(channel);

                if (!_channels[channel].Equals(otherChannel))
                {
                    return(false);
                }
            }

            return(true);
        }