Iplimage structure in opencv

Source: Internet
Author: User
Typedef struct _ iplimage {int nsize;/* sizeof (iplimage) */int id;/* version (= 0) */INT nchannels;/* Most of opencv Functions Support 1, 2, 3 or 4 channels */INT alphachannel;/* ignored by opencv */INT depth;/* pixel depth in bits: Average, minimum, ipl_depth_16s, ipl_depth_32s, minimum and maximum are supported. */Char colormodel [4];/* ignored by opencv */Char Channel SEQ [4];/* ditto */INT dataorder;/* 0-interleaved color channels, 1-separate color channels. cvcreateimage can only create interleaved images */INT origin;/* 0-top-left origin, 1-bottom-left origin (Windows bitmaps style ). */INT align;/* alignment of image rows (4 or 8 ). opencv ignores it and uses widthstep instead. */INT width;/* Image Width in pixels. */INT height;/* image heig Ht in pixels. */struct _ iplroi * roi;/* Image ROI. if null, the whole image is selected. */struct _ iplimage * maskroi;/* must be null. */void * imageid;/* "*/struct _ ipltileinfo * tileinfo;/*" */INT imagesize; /* image data size in bytes (= image-> height * image-> widthstep in case of interleaved data) */char * imagedata;/* pointer to aligned image data. */INT widthstep;/* size of aligne D image row in bytes. */INT bordermode [4];/* ignored by opencv. */INT borderconst [4];/* ditto. */char * imagedataorigin;/* pointer to very origin of image data (not necessarily aligned)-needed for correct deallocation */} iplimage; this structure is defined in the header file types_c.h (opencv2 \ core \ types_c.h ).
Width and height indicate the image width and height, respectively. They are the two most important members in this structure.
The second is the depth and nchannals variables:
The value of the depth variable is taken from types_c.h.
# Define ipl_depth_sign 0x80000000 # define ipl_depth_1u 1 // unsigned 1-bit integer # define ipl_depth_8u 8 // unsigned 8-bit integer # define ipl_depth_16u 16 // unsigned 16 # define ipl_depth_32f 32 // 32-bit floating point number single precision # define ipl_depth_8s (ipl_depth_sign | 8) // signed 8-bit integer # define ipl_depth_16s (ipl_depth_sign | 16) // signed 16-bit integer # define ipl_depth_32s (ipl_depth_sign | 32) // signed 32-bit integer

Number of channels nchannels can be set to 1, 2, 3, or 4.

The following two important members are origin and dataorder:

The origin variable can have two values: ipl_origin_tl or ipl_origin_bl. The coordinates of the origin are set in the upper left or lower left corner of the image. Generally, image sources, operating systems, codecs, and storage formats all affect image origin selection. Check the system before starting image operations, it is a good method to draw something in the place where the image block is operated;

The value of dataorder can be ipl_data_order_pixel or ipl_data_order_plane. The former indicates that data is to splice values of different pixel channels together (this is a common Staggered Arrangement ), the latter arranges all pixels in the same channel value to form a channel plane and then arrange the plane.

Dataorder = ipl_data_order_plane, the total number of rows is height * nchannels.

To process images more efficiently, each row is aligned with a fixed byte. Therefore, the width cannot be used as the number of bytes between the points in the same column of the adjacent row. The widthstep variable is set for this purpose.

The imagedata parameter contains a pointer pointing to the first address of the image data area.

The ROI parameter, the region of interest, is actually an instance of iplroi:

typedef struct _IplROI{    int  coi; /* 0 - no COI (all channels are selected), 1 - 0th channel is selected ...*/    int  xOffset;    int  yOffset;    int  width;    int  height;}IplROI;

The idea of ROI is that once the ROI is set, the function typically acts on the entire image only performs operations on the sub-image represented by the ROI.

If the ROI is set in the iplimage variable, all opencv functions use this ROI variable.

If COI is set to a non-zero value, the operation on the image only applies to the specified channel. COI may have 1, 2, 3, and 4 channels, in addition, the value 0 is reserved to make COI invalid. In opencv, many functions ignore COI.

The cvsetimageroi (iplimage * image, cvrect rect) and cvresetimageroi () functions are used to set and cancel the ROI respectively.

The above full text comes from learning opencv. It can be viewed as not being modified.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.