(1) Allocate memory to a new image:
iplimage* cvcreateimage (cvsize size, int depth, int channels); size -image width, height. Depth -the bit depth of the image element, which can be one of the following: ipl_depth_8u-Unsigned 8-bit integer ipl_depth_8s-Signed 8-bit integer ipl_depth_16u-unsigned 16-bit integer ipl_depth_16s-signed 16-bit integer ipl_ Depth_32s-Signed 32-bit integer ipl_depth_32f-single-precision floating-point number ipl_depth_64f-double-precision floating-point numbers channels-the amount of color channels per element (pixel). can be 1, 2, 3 or 4. Channels are cross-stored For example, the usual color image data arrangement is: B0G0 r0 B1 g1 R1 ...
Example
Iplimage*img=cvcreateimage (Cvsize (640,480), ipl_depth_8u,1);
(2) Release the Image:
Iplimage*img=cvcreateimage (Cvsize (640,480), ipl_depth_8u,1); Cvreleaseimage (&img);
(3) Copy Image:
Iplimage*img1=cvcreateimage (Cvsize (640,480), ipl_depth_8u,1); Iplimage*img2;img2=cvcloneimage (IMG1); Note that images obtained by Cvcloneimage are also released with Cvreleaseimage, otherwise prone to memory leaks
(4) setting, acquiring, and releasing ROI for an area of interest:
Set the image Roi region void Cvsetimageroi (iplimage* image, Cvrect rect);//Release the image based on the given matrix settings roivoid Cvresetimageroi ( iplimage* image);//Returns the ROI coordinate cvrect cvgetimageroi (const iplimage* image);
Most OPENCV functions support roi,region of interests, and after the ROI is set, the function's processing of the image will only be applied to the ROI region.
Memory allocation and release of "OpenCV" images, copying images and setting image ROI region