Halcon-image pixel type and conversion

Image type

As far as the mainstream image processing tool halcon in the industrial field is concerned, there are the following image types:'byte','complex','cyclic','direction','int1','int2','int4','int8 ','real','uint2', the specific meaning is shown in the figure below. Insert picture description here
'byte' 1 byte per pixel, unsigned value range: (0 to 255)
'int1' 1 byte per pixel, signed value range: (-128 to 127)
'uint2' 2 bytes per pixel, unsigned Value range: (0 to 65535)
'int2' 2 bytes per pixel, signed value range: (-32768 to 32767)
'int4' 4 bytes per pixel, signed value range: (-2147483648 to 2147483647)
'int8 '8 bytes per pixel, signed (only for x64 systems)
'real' 4 bytes per pixel, floating point type, 6 valid decimal digits. Precision value range: (-3.4e38 to 3.4e38)
'complex' real Two matrices of type vector, two matrices of
real type vector'vector_field_relative', two matrices of
real type vector'vector_field_absolute', absolute coordinate'direction
' 1 byte per pixel, unsigned value range: (0 to 179), Divide the angle by 2
Note: The value 180 to 254 is automatically set to the value 255.
'cyclic' 1 byte per pixel, unsigned, cyclic arithmetic range: (0 to 255)

Conversion

halcon self-conversion

The conversion between each other can be completed by the convert_image_type operator, but blind conversion will cause abnormal image pixel values.

But why the conversion? To sum up, there are several reasons:
1. For example, byte and unit2 are both unsigned types. If image subtraction operations are involved, they need to be converted to signed types to generate real values.
2. When it comes to traversing image operations, if the length of the array is the product of length and width, and exceeds the maximum number of pixels in the image, it will cause the program to report an error. You must give the array more space, which requires type conversion.
3. If an image with a high pixel value wants to be converted to an image with a low pixel value, it cannot be directly converted, and the image pixels must be scaled first through the scale_image operator.

halcon to C# type

1. Int, double, string, IntPtr
are all completed by adding .I(), .D(), .S(), .IP() to the variable name of the Htuple type.

The cited article is as follows:
Introduction to the most complete image format of halcon

Guess you like

Origin blog.csdn.net/baidu_35536188/article/details/113683436