image_to_memory_blockT_image_to_memory_blockImageToMemoryBlockImageToMemoryBlockimage_to_memory_block (算子)

名称

image_to_memory_blockT_image_to_memory_blockImageToMemoryBlockImageToMemoryBlockimage_to_memory_block — 以各种图形格式将图像写入存储块。

签名

image_to_memory_block(Image : : Format, FillColor : MemoryBlockHandle)

Herror T_image_to_memory_block(const Hobject Image, const Htuple Format, const Htuple FillColor, Htuple* MemoryBlockHandle)

void ImageToMemoryBlock(const HObject& Image, const HTuple& Format, const HTuple& FillColor, HTuple* MemoryBlockHandle)

HMemoryBlock HImage::ImageToMemoryBlock(const HString& Format, const HTuple& FillColor) const

HMemoryBlock HImage::ImageToMemoryBlock(const HString& Format, Hlong FillColor) const

HMemoryBlock HImage::ImageToMemoryBlock(const char* Format, Hlong FillColor) const

HMemoryBlock HImage::ImageToMemoryBlock(const wchar_t* Format, Hlong FillColor) const   ( Windows only)

static void HOperatorSet.ImageToMemoryBlock(HObject image, HTuple format, HTuple fillColor, out HTuple memoryBlockHandle)

HMemoryBlock HImage.ImageToMemoryBlock(string format, HTuple fillColor)

HMemoryBlock HImage.ImageToMemoryBlock(string format, int fillColor)

def image_to_memory_block(image: HObject, format: str, fill_color: Union[int, float]) -> HHandle

描述

算子 image_to_memory_blockimage_to_memory_blockImageToMemoryBlockImageToMemoryBlockImageToMemoryBlockimage_to_memory_block saves the input image ImageImageImageImageimageimage to the memory block MemoryBlockHandleMemoryBlockHandleMemoryBlockHandleMemoryBlockHandlememoryBlockHandlememory_block_handle in the format FormatFormatFormatFormatformatformat. If the domain (region) cannot be saved in the specified FormatFormatFormatFormatformatformat (this is the case for 'jpeg'), all pixels outside the region receive the color defined by FillColorFillColorFillColorFillColorfillColorfill_color. For gray value images a value between 0 (black) and 255 (white) must be passed. For RGB color images the RGB values can be passed directly as a hexadecimal value: e.g., 0xffff00 for a yellow background (red=255, green=255, blue=0).

The following formats can be set in FormatFormatFormatFormatformatformat:

'jpeg': JPEG format (lossy compression), file extension *.jpg

This format can only store images with one channel (gray value image) or three channels (RGB image).

Only images with the pixel type byte are supported for this file format.

Together with the format string the quality value determining the compression rate can be provided. Large values (maximum 100) create a large memory block with high image quality. Small values significantly decrease the image quality and the size of the memory block.

Possible values: 'jpeg'"jpeg""jpeg""jpeg""jpeg""jpeg", 'jpeg 30'"jpeg 30""jpeg 30""jpeg 30""jpeg 30""jpeg 30", 'jpeg 60'"jpeg 60""jpeg 60""jpeg 60""jpeg 60""jpeg 60".

Attention: Images stored for being processed later should not be stored in this format due to the loss of information during compression.

'png': PNG format (lossless compression), file extension *.png

This format can only store images with one channel (gray value image) or three channels (RGB image). The maximal supported image size (width x height) for PNG is , also in HALCON XL.

Images of type byte and uint2 can be stored in PNG format.

Together with the format string, a compression level between 0 and 9 can be specified, where 0 corresponds to no compression and 9 to the best possible compression. Alternatively, the compression can be selected by using string constants.

Possible values: 'png'"png""png""png""png""png", 'png 7'"png 7""png 7""png 7""png 7""png 7", 'png none'"png none""png none""png none""png none""png none", 'png best'"png best""png best""png best""png best""png best", 'png fastest'"png fastest""png fastest""png fastest""png fastest""png fastest".

If an image with a reduced domain is written, the region is stored as the alpha channel, where the points within the domain are stored as the maximum gray value of the image type and the points outside the domain are stored as the gray value 0. If an image with a full domain is written, no alpha channel is stored.

执行信息

此算子返回一个句柄。请注意,即使该句柄被用作特定算子的输入参数,这些算子仍可能改变此句柄类型的实例状态。

参数

ImageImageImageImageimageimage (输入对象)  (multichannel-)image objectHImageHObjectHImageHobject (byte / direction / cyclic / int1 / complex / int2 / uint2 / vector_field / int4 / int8 / real)

输入图像。

FormatFormatFormatFormatformatformat (输入控制)  string HTuplestrHTupleHtuple (string) (string) (HString) (char*)

Graphic format.

默认值: 'jpeg' "jpeg" "jpeg" "jpeg" "jpeg" "jpeg"

建议值: 'jpeg'"jpeg""jpeg""jpeg""jpeg""jpeg", 'png'"png""png""png""png""png"

FillColorFillColorFillColorFillColorfillColorfill_color (输入控制)  number HTupleUnion[int, float]HTupleHtuple (integer / real) (int / long / double) (Hlong / double) (Hlong / double)

Gray value for pixels not belonging to the image domain (region).

默认值: 0

建议值: -1, 0, 255, 65280, 16711680

MemoryBlockHandleMemoryBlockHandleMemoryBlockHandleMemoryBlockHandlememoryBlockHandlememory_block_handle (输出控制)  memory_block HMemoryBlock, HTupleHHandleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)

Memory block handle.

结果

如果参数值正确,算子 image_to_memory_blockimage_to_memory_blockImageToMemoryBlockImageToMemoryBlockImageToMemoryBlockimage_to_memory_block 返回值 2 ( H_MSG_TRUE )。否则将抛出异常。

可能的前趋

open_windowopen_windowOpenWindowOpenWindowOpenWindowopen_window, read_imageread_imageReadImageReadImageReadImageread_image

可能的后继

write_memory_blockwrite_memory_blockWriteMemoryBlockWriteMemoryBlockWriteMemoryBlockwrite_memory_block, serialize_tupleserialize_tupleSerializeTupleSerializeTupleSerializeTupleserialize_tuple

模块

基础