Halcon 读取区域的灰度值

主要使用intensity()这个函数

halcon程序:

*读取图片,转换成灰度图片

read_image (Image1, 'C:/Users/Administrator/Desktop/12.png.tif')
rgb1_to_gray (Image1, Image)

*选择测量的区域

draw_rectangle1 (3600, Row1, Column1, Row2, Column2)
gen_rectangle1 (Rectangle, Row1, Column1, Row2, Column2)

*检测灰度
intensity (Rectangle, Image, Mean, Deviation)
dev_display (Image)
 

 

C#程序:

            HTuple row1,row2,col1,col2;
            HOperatorSet.SetColor(Image1.HalconWindow, "red");

            Image1.HalconWindow.SetDraw("margin");

//选择区域
            HOperatorSet.DrawRectangle1(Image1.HalconWindow, out row1, out col1, out row2, out col2);
           
            Image1.HalconWindow.DispRectangle1(row1,col1,row2,col2);
            HOperatorSet.DispObj(ho_Image1,Image1.HalconWindow);
            HObject rect1;
            HOperatorSet.GenRectangle1(out rect1, row1, col1, row2, col2);
            HTuple mean, deviation;
            HOperatorSet.Intensity(rect1, ho_Image1,out mean, out deviation);
            textBox1.Text = mean.ToString() + "-" + deviation.ToString();

 

 

 

 

©️2020 CSDN 皮肤主题: 编程工作室 设计师:CSDN官方博客 返回首页