The following are some knowledge points:
(1) path setting: Generally, you need to save the folder containing images to the project directory, that is, ensure that the folder and debug are under the same root directory;
(2) cvsetimageroi and cvcopy functions:
Cvsetimageroi (iplimage * DST, cvrect (left border, upper border, width, height )). This function is to open the cvrect rectangular frame area memory space in the image DST, and then cvcopy (iplimage * SRC, iplimage * DST) the function copies the source image SRC to the destination image DST.
ReferenceCode:
# Include <cv. h>
# Include
Int main (INT argc, char * argv [])
{
Iplimage * src1;
Iplimage * src2;
Iplimage * des;
Src1 = cvloadimage ("111.jpg", 0 );
Src2 = cvloadimage ("222.jpg", 0 );
Des = cvcreateimage (cvsize (1200,450), src1-> depth, src1-> nchannels );
//----------------------------------
// Load the original image to the Target Image
Cvsetimageroi (DES, cvrect (0, 0,600,450 ));
Cvcopy (src1, des );
Cvresetimageroi (DES );
Cvsetimageroi (DES, cvrect (600, 0,600,450 ));
Cvcopy (src2, des );
Cvresetimageroi (DES );
Cvnamedwindow ("image merging", 1 );
Cvshowimage ("image merging", des );
Cvwaitkey (0 );
Cvreleaseimage (& src1 );
Cvreleaseimage (& src2 );
Cvreleaseimage (& des );
Cvdestroywindow ("image merging ");
Return 0;
}
Running result: