AForge.Imaging.Filters.OtsuThreshold.CalculateThreshold C# (CSharp) Метод

CalculateThreshold() публичный Метод

Calculate binarization threshold for the given image.

The method is used to calculate binarization threshold only. The threshold later may be applied to the image using Threshold image processing filter.

Source pixel format is not supported by the routine. It should be /// 8 bpp grayscale (indexed) image.
public CalculateThreshold ( Bitmap image, Rectangle rect ) : int
image System.Drawing.Bitmap Image to calculate binarization threshold for.
rect System.Drawing.Rectangle Rectangle to calculate binarization threshold for.
Результат int
        public int CalculateThreshold( Bitmap image, Rectangle rect )
        {
            int calculatedThreshold = 0;

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

            try
            {
                calculatedThreshold = CalculateThreshold( data, rect );
            }
            finally
            {
                // unlock image
                image.UnlockBits( data );
            }

            return calculatedThreshold;
        }

Same methods

OtsuThreshold::CalculateThreshold ( BitmapData image, Rectangle rect ) : int
OtsuThreshold::CalculateThreshold ( UnmanagedImage image, Rectangle rect ) : int