C# 클래스 AForge.Imaging.Filters.IterativeThreshold

Iterative threshold search and binarization.

The algorithm works in the following way: select any start threshold; compute average value of Background (µB) and Object (µO) values: 1) all pixels with a value that is below threshold, belong to the Background values; 2) all pixels greater or equal threshold, belong to the Object values. calculate new thresghold: (µB + µO) / 2; if |oldThreshold - newThreshold| is less than a given manimum allowed error, then stop iteration process and create the binary image with the new threshold.

For additional information see Digital Image Processing, Gonzalez/Woods. Ch.10 page:599.

The filter accepts 8 and 16 bpp grayscale images for processing.

Since the filter can be applied as to 8 bpp and to 16 bpp images, the initial value of Threshold.ThresholdValue property should be set appropriately to the pixel format. In the case of 8 bpp images the threshold value is in the [0, 255] range, but in the case of 16 bpp images the threshold value is in the [0, 65535] range.

Sample usage:

// create filter IterativeThreshold filter = new IterativeThreshold( 2, 128 ); // apply the filter Bitmap newImage = filter.Apply( image );

Initial image:

Result image (calculated threshold is 102):

상속: Threshold
파일 보기 프로젝트 열기: holisticware-admin/MonoVersal.AForgeNET 1 사용 예제들

공개 메소드들

메소드 설명
CalculateThreshold ( Bitmap image, Rectangle rect ) : int

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.

CalculateThreshold ( BitmapData image, Rectangle rect ) : int

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.

CalculateThreshold ( UnmanagedImage image, Rectangle rect ) : int

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.

IterativeThreshold ( ) : System

Initializes a new instance of the IterativeThreshold class.

IterativeThreshold ( int minError ) : System

Initializes a new instance of the IterativeThreshold class.

IterativeThreshold ( int minError, int threshold ) : System

Initializes a new instance of the IterativeThreshold class.

보호된 메소드들

메소드 설명
ProcessFilter ( UnmanagedImage image, Rectangle rect ) : void

Process the filter on the specified image.

메소드 상세

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 /// 8 bpp grayscale (indexed) or 16 bpp grayscale 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

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 /// 8 bpp grayscale (indexed) or 16 bpp grayscale image.
public CalculateThreshold ( BitmapData image, Rectangle rect ) : int
image System.Drawing.Imaging.BitmapData Image to calculate binarization threshold for.
rect System.Drawing.Rectangle Rectangle to calculate binarization threshold for.
리턴 int

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 /// 8 bpp grayscale (indexed) or 16 bpp grayscale image.
public CalculateThreshold ( UnmanagedImage image, Rectangle rect ) : int
image UnmanagedImage Image to calculate binarization threshold for.
rect System.Drawing.Rectangle Rectangle to calculate binarization threshold for.
리턴 int

IterativeThreshold() 공개 메소드

Initializes a new instance of the IterativeThreshold class.
public IterativeThreshold ( ) : System
리턴 System

IterativeThreshold() 공개 메소드

Initializes a new instance of the IterativeThreshold class.
public IterativeThreshold ( int minError ) : System
minError int Minimum allowed error, that ends the iteration process.
리턴 System

IterativeThreshold() 공개 메소드

Initializes a new instance of the IterativeThreshold class.
public IterativeThreshold ( int minError, int threshold ) : System
minError int Minimum allowed error, that ends the iteration process.
threshold int Initial threshold value.
리턴 System

ProcessFilter() 보호된 메소드

Process the filter on the specified image.
protected ProcessFilter ( UnmanagedImage image, Rectangle rect ) : void
image UnmanagedImage Source image data.
rect System.Drawing.Rectangle Image rectangle for processing by the filter.
리턴 void