阀值处理-----一般应用在二值化上
其他颜色也是可以应用。
以下会生产新的图像。
public Image<TColor, TDepth> ThresholdAdaptive( TColor maxValue, AdaptiveThresholdType adaptiveType, ThresholdType thresholdType, int blockSize, TColor param1 )
public Image<TColor, TDepth> ThresholdBinary( TColor threshold, TColor maxValue )
public Image<TColor, TDepth> ThresholdBinaryInv( TColor threshold, TColor maxValue )
public Image<TColor, TDepth> ThresholdToZero( //低于值全为0 TColor threshold )
public Image<TColor, TDepth> ThresholdToZeroInv( TColor threshold)
//高于值全为255
public Image<TColor, TDepth> ThresholdTrunc( TColor threshold //大于阀值,变成阀值 )
以下是对本图片进行处理:请注意!跟上面是一样模式。
public void _ThresholdBinary( TColor threshold, TColor maxValue )
public void _ThresholdBinaryInv( TColor threshold, TColor maxValue )
public void _ThresholdToZero( TColor threshold )
public void _ThresholdToZeroInv( TColor threshold )
public void _ThresholdTrunc( TColor threshold )
实例练习学习
Emgu.CV.Image<Gray,byte> GAY1 = new Image<Gray, byte>((Bitmap)pictureBox2.Image);
pictureBox5.Image = GAY1.ThresholdBinary(new Gray((int)numericUpDown1.Value), new Gray(250)).Bitmap;
pictureBox4.Image = GAY1.ToBitmap(); //灰度图片
反变二值化
Emgu.CV.Image<Gray,byte> GAY1 = new Image<Gray, byte>((Bitmap)pictureBox2.Image);
pictureBox5.Image = GAY1.ThresholdBinaryInv(new Gray((int)numericUpDown1.Value), new Gray(250)).Bitmap;pictureBox4.Image = GAY1.ToBitmap();
pictureBox4.Image = GAY1.ToBitmap();
pictureBox5.Image = GAY1.ThresholdToZero(new Gray((int)numericUpDown1.Value)).Bitmap;
pictureBox4.Image = GAY1.ToBitmap();
pictureBox5.Image = GAY1.ThresholdToZeroInv(new Gray((int)numericUpDown1.Value)).Bitmap;
pictureBox4.Image = GAY1.ToBitmap();
pictureBox5.Image = GAY1.ThresholdTrunc(new Gray((int)numericUpDown1.Value)).Bitmap;
自适应阀值
pictureBox2.Image=YUAN.Convert<Gray,Byte>().ThresholdAdaptive(newGray(250), Emgu.CV.CvEnum.AdaptiveThresholdType.GaussianC,Emgu.CV.CvEnum.ThresholdType.Binary,3,new Gray(0)).ToBitmap();