This interface expose APIs to access/manipulate/draw a LPV LImage object. More...
Public Member Functions | |
void | CopyFrom (ILImage *img, ILRegion *region, int panX, int panY) |
void | CopyTo (ILImage *dstImg) |
void | Draw (HDC hdc, double zoomX, double zoomY, double panX, double panY) |
void | DrawAsMask (HDC hdc, double zoomX, double zoomY, double panX, double panY) |
ILImage * | GetChannel (int channelIdx) |
LPVErrorCode | LoadRawFile (LString filename, int w, int h, int flags) |
LPVErrorCode | Save (LString filename, ILRegion *region) |
void | SetChannel (int channelIdx, ILImage *channelImage) |
void | SetImageData (int w, int h, LPVOID dataPtr, int bpl, BOOL copyData) |
void | SetSize (int w, int h) |
void | SetTo (int val, ILRegion *region) |
void | SetToColor (LColor val, ILRegion *region) |
Public Member Functions inherited from ILObject | |
ILObject * | Copy () |
LPVErrorCode | Load (LString filename) |
void | Reset () |
LPVErrorCode | Save (LString filename) |
BOOL | Valid () |
Properties | |
int | BytesPerLine [get] |
The number of bytes contained in a row, include the padding bytes. | |
LPVOID | DataPointer [get] |
The pointer to the image data buffer. Please DON'T change the content of the data block. | |
int | Height [get] |
The height of the image, number of rows. | |
LPVImageFormat | ImageFormat [get, set] |
The format of the image. | |
int | Pixel (int x, int y) [get, set] |
LColor | PixelColor (int x, int y) [get, set] |
int | Width [get] |
The width of the image, number of columns. | |
This interface expose APIs to access/manipulate/draw a LPV LImage object.
Image is the core object in a vision system. The image class encapsulate all the functionality needed to represent a rectangular shaped image. It stores pixels as a 2-dimensional dense array, row by row.
To use this interface, you should create a LImage object.
There are many different ways to initialize data of the image. The most popular options are listed below:
Copy the content of the input image and cover the current.
[in] | img | The input image. If the input image is bigger or outside with the given x/y offset, the redundant part will be ignored. |
[in] | region | The input region to crop the input image. Optional, could be null. |
[in] | panX | The x-coordinate of the offset |
[in] | panY | The y-coordinate of the offset |
void CopyTo | ( | ILImage * | dstImg | ) |
Copy the image object to destination.
If the current image object has its own data buffer, we'll do another clone of data to the destination image object. Otherwise, we just simply assign the data pointer to it.
[out] | dstImg | The destination image object. |
void Draw | ( | HDC | hdc, |
double | zoomX, | ||
double | zoomY, | ||
double | panX, | ||
double | panY | ||
) |
Draw the image onto the provided device context.
void DrawAsMask | ( | HDC | hdc, |
double | zoomX, | ||
double | zoomY, | ||
double | panX, | ||
double | panY | ||
) |
Draw the image as a mask onto the provided device context, white pixels preserve the original values on HDC.
ILImage* GetChannel | ( | int | channelIdx | ) |
Extract the channel of the given index. This function is only for a color image.
[in] | channelIdx | The input channel index, 0, 1 or 2. |
channelImage | Return the channel image. It's a grayscale image of the same size as the current color image. |
LPVErrorCode LoadRawFile | ( | LString | filename, |
int | w, | ||
int | h, | ||
int | flags | ||
) |
Load image from .raw file.
[in] | w | The width of the image in pixels, should be a positive value. Since .raw format does not include informations for image size, the caller should set the size manually. | ||||||
[in] | h | The height of the image in pixels, should be a positive value. | ||||||
[in] | flags | Controls how to parse the raw data
| ||||||
[in] | filename | Full path of the file, it could be absolute or relative path with file name and extension. |
error | Return error code if anything is wrong. |
LPVErrorCode Save | ( | LString | filename, |
ILRegion * | region | ||
) |
Save the image object to a specified file. The image format is chosen based on the filename extension. Currently, we support save as BMP, PNG, JPG, JPEG formats.
[in] | region | Optional, could be null. If you want to only save part of the image, pass in a region. |
[in] | filename | Full path of the file, it could be absolute or relative path with file name and extension. |
error | Return error code if anything is wrong. |
void SetChannel | ( | int | channelIdx, |
ILImage * | channelImage | ||
) |
Set the channel of the given index to the input grayscale image. This function is only for a color image.
[in] | channelIdx | The input channel index, 0, 1 or 2. |
[in] | channelImage | The input grayscale channel image, it should be of the same size as the current color image. |
void SetImageData | ( | int | w, |
int | h, | ||
LPVOID | dataPtr, | ||
int | bpl, | ||
BOOL | copyData | ||
) |
Assign data to the image object via an external allocated buffer.
If copyData is set to False, this pointer overwrite the internally allocated buffer inside the image object. You should take the responsibility to keep the buffer alive during the entire life cycle of the image object.
If copyData is set to True, we'll copy the content into the buffer owned by the image object. You don't need to worry about the data life cycle then.
[in] | w | The width of the image in pixels, should be a positive value. |
[in] | h | The height of the image in pixels, should be a positive value. |
[in] | dataPtr | Pointer to the external image data buffer. |
[in] | bpl | Bytes per line, the number of bytes contained in a row. The value should include the padding bytes. at the end of each row, if any. If set to 0, no padding is assumed and the actual stride is calculated as column number * pixel size(sizeof(char)). |
[in] | copyData | Whether to copy the data into owned buffer of the image object. |
void SetSize | ( | int | w, |
int | h | ||
) |
Change the size of image to provided size. The pixel values are undefined. You may set them all to 0 or other preferred value via SetTo() or SetToColor(). If the image is already of the same, we keep the old data. Pass in 0 width or 0 height to reset the image to be empty.
[in] | w | Required image width. |
[in] | h | Required image height. |
void SetTo | ( | int | val, |
ILRegion * | region | ||
) |
Set the pixels in the given region to the specified grayscale value. For a color image, all its channels are set to the same value.
[in] | val | The grayscale value |
[in] | region | The input region. If the input region is bigger or outside of the image, the redundant part will be ignored. Optional, could be null, which mean the entire image. |
Set the pixels in the given region to the specified RGB color value. This function is only for a color image.
[in] | val | The color value |
[in] | region | The input region. If the input region is bigger or outside of the image, the redundant part will be ignored. Optional, could be null, which mean the entire image. |
|
getset |
The pixel's grayscale value.
[in] | x | The x-coordinate of the pixel. |
[in] | y | The y-coordinate of the pixel. |
|
getset |
The pixel's color value.
[in] | x | The x-coordinate of the pixel. |
[in] | y | The y-coordinate of the pixel. |