AForge.Imaging.ImageStatisticsYCbCr.ImageStatisticsYCbCr C# (CSharp) Method

ImageStatisticsYCbCr() public method

Initializes a new instance of the ImageStatisticsYCbCr class.

The mask array must be of the same size as the specified source image, where 0 values correspond to areas which should be excluded from processing. So statistics is calculated only for pixels, which have none zero corresponding value in the mask.

Source pixel format is not supported. Mask must have the same size as the source image to get statistics for.
public ImageStatisticsYCbCr ( Bitmap image, byte mask ) : System
image System.Drawing.Bitmap Image to gather statistics about.
mask byte Mask array which specifies areas to collect statistics for.
return System
        public ImageStatisticsYCbCr( Bitmap image, byte[,] mask )
        {
            CheckSourceFormat( image.PixelFormat );
            CheckMaskProperties( PixelFormat.Format8bppIndexed,
                new Size( mask.GetLength( 1 ), mask.GetLength( 0 ) ), new Size( image.Width, image.Height ) );

            // lock bitmap data
            BitmapData imageData = image.LockBits(
                new Rectangle( 0, 0, image.Width, image.Height ),
                ImageLockMode.ReadOnly, image.PixelFormat );

            try
            {
                // gather statistics
                unsafe
                {
                    fixed ( byte* maskPtr = mask )
                    {
                        ProcessImage( new UnmanagedImage( imageData ), maskPtr, mask.GetLength( 1 ) );
                    }
                }
            }
            finally
            {
                // unlock image
                image.UnlockBits( imageData );
            }
        }

Same methods

ImageStatisticsYCbCr::ImageStatisticsYCbCr ( Bitmap image ) : System
ImageStatisticsYCbCr::ImageStatisticsYCbCr ( Bitmap image, Bitmap mask ) : System
ImageStatisticsYCbCr::ImageStatisticsYCbCr ( UnmanagedImage image ) : System
ImageStatisticsYCbCr::ImageStatisticsYCbCr ( UnmanagedImage image, UnmanagedImage mask ) : System
ImageStatisticsYCbCr::ImageStatisticsYCbCr ( UnmanagedImage image, byte mask ) : System