halcon基本示例之灰度直方图

来源:互联网 发布:怎样下载cad软件 编辑:程序博客网 时间:2024/06/05 01:17
void test(){    HImage image("2.jpg");    HImage gray = image.Rgb1ToGray();//转化为灰度图    Hlong width, height;    image.GetImageSize(&width, &height);    HRegion region;    region.GenRectangle1(0, 0, height-1, width-1);//创建一个矩形    HTuple AbsoluteHisto, RelativeHisto;    AbsoluteHisto = region.GrayHisto(image, &RelativeHisto);//获得区域内的灰度值分布AbsoluteHisto表示灰度值对应像素个数,RelativeHisto代表归一化后值     HRegion histo;    histo.GenRegionHisto(AbsoluteHisto, 0, 0, 1);//根据AbsoluteHisto或者RelativeHisto生成灰度直方图区域    HWindow w(0, 0, 500, 500);    HWindow w0(0, 0, width, height);    w.SetColor("red");    w.DispRegion(histo);    w0.DispImage(gray);    w.Click();}
1 0
原创粉丝点击