右移i位 HByteImage operator ~ (void)
对每个像素去补 HByteImage operator & (HByteImage &ima)
两图像对应像素取 & HByteImage operator | (HByteImage &ima)
两图像对应像素取 | HByteImage operator ^ (HByteImage &ima)
两图像对应像素取 异或
例5
#include "HalconCpp.h" #include "HIOStream.h" #if !defined(USE_IOSTREAM_H) using namespace std; #endif using namespace Halcon; void main() { HByteImage in("E:\\halcon\\images\\mreut.png"); // Aerial image HWindow w; // Output window in.Display(w); // Displaying the image HByteImage out = in; // Copying the image int width = out.Width(); // Width of the image int height = out.Height(); // Height of the image long end = width * height; // Number of pixel of the image // 1. run: linear accessing for (long k = 0; k < end; k++) { out[k] = 255 - in[k]; // Setting the pixel } // Displaying the transformation cout << "Transformed !" << endl; out.Display(w); w.Click(); cout << "Original !" << endl; in.Display(w); w.Click(); // 2. run: accessing the image via the coordinates (x,y) for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { out(x, y) = 255 - in(x, y); // Setting the pixel } } // Displaying the transformation cout << "Transformed !" << endl; out.Display(w); w.Click(); cout << "Original !" << endl; in.Display(w); w.Click(); }
本例是例4的改造版,看起来更简洁,更像C语言的风格。访问像素不再需要get/set格式。
XLD Objects
XLD是eXtented Line Description的简称。这种数据结构可以描述areas(即任意大小的区域或者多边形)or 任何封闭的或者打开的轮廓。与regions代表像素精度相反,XLD代表的是亚像素精度。其中有两种基本的XLD结构: 轮廓(contours)和 多边形(polygons).
与图像相似,HALCON/C++也提供了基类HXLD和一些继承自HXLD的特殊类,比如HXLDCont用于轮廓,HXLDPoly用于多边形。另外也存在一个容器类,即HXLDArray.
Low—Level Iconic Objects
当以面向过程的方式调用算子时,Hobject可以被用来代表所有的图像参数,如 an image,a region,an image array.事实上,Hobject是HALCON访问内部数据的基类。并且,Hobejct也可作为HObject和HObject继承类,如HImage的基类。
Hobject有如下的成员函数:
Hobject(void) Default constructor. Hobject(const Hobject &obj) Copy constructor. virtual ~Hobject(void) Destructor. Hobject &operator = (const Hobject &obj) Assignment operator. void Reset(void) Freeing the memory and resetting the corresponding database key.
正如前面所讲,Hobject的对象也可以包含一个图像数据的数组。但是不幸的是,Hobject没有特殊的函数区增加和选择数组成员,取而代之的是,你必须使用“The Tuple Mode”.一节所描述的算子gen_empty_obj, concat_obj, select_obj, and count_obj 代替。