ProgramIf you do not understand the function, please refer to this CHM document, www.opencv.org.cn/index.php/download, with the search function, equivalent to msdnof mfc. ====================================== The second example is the image size Transformation: # Include <Cv. h> # Include # Include <math. h> Int Main (INT argc, char * argv []) { Iplimage * src = 0; Iplimage * DST = 0; Double scale = 0.618; // Scaling Factor Cvsize dst_cvsize; // Used to store the image size If (Argc = 2 & (src = cvloadimage (argv [1],-1 ))! = 0) { Dst_cvsize.width = (INT) (SRC-> width * scale ); // Width of the source Image Dst_cvsize.height = (INT) (SRC-> height * scale ); // Height of the source Image DST = cvcreateimage (dst_cvsize, Src-> depth, Src-> nchannels ); // Create an image Cvresize (SRC, DST, cv_inter_linear ); // Implement size conversion Cvnamedwindow ("src", cv_window_autosize ); Cvnamedwindow ("DST", cv_window_autosize ); Cvshowimage ("src", Src ); Cvshowimage ("DST", DST ); Cvwaitkey (0 ); Cvreleaseimage (& SRC ); Cvreleaseimage (& DST ); Cvdestroywindow ("src "); Cvdestroywindow ("DST "); } Return 0; } ====================================== The second parameter of cvloadimage is different from the previous one, specifically: # Define Cv_load_image_unchanged-1 # Define cv_load_image_grayscale 0 # Define Cv_load_image_color 1 # Define cv_load_image_anydepth 2 # Define Cv_load_image_anycolor 4 We can see from the macro definition that different colors and depths of the image. If you want to load the most authentic image, select cv_load_image_anydepth | Cv_load_image_anycolor. cvloadimage currently supports the following file formats: Windows bitmap file-BMP, Dib; JPEG file-JPEG, JPG, jpe; portable network image-PNG; portable image formats-PBM, PGM, and ppm; sun rasters-Sr, Ras; TIFF file-Tiff, Tif; openexr HDR Image-EXR; JPEG 2000 image-JP2. Source Address: http://hi.baidu.com/gilbertjuly/blog/item/25e4cd3f08ee733471cf6c82.html |