1, the image reading and display
#include <iostream>#include<opencv2/core/core.hpp>#include<opencv2/highgui/highgui.hpp>using namespacestd;using namespaceCV; intMainintargcint*argv[]) {Mat image= Imread ("lena.bmp"); Namedwindow ("Original Image"); Imshow ("Image", image); Waitkey (6000); return 0; }
where Imread (); the function has three parameters, respectively:
Cv_load_image_color (>0) RGB color mode
Cv_load_image_grayscale (0) Grayscale image mode
Cv_load_image_unchanged m (<0) depends on the image condition
/*turn an image into a grayscale image*/#include<iostream>#include<cv.h>#include<opencv2/core/core.hpp>#include<opencv2/highgui/highgui.hpp>using namespacestd;using namespaceCV; intMainintargcint*argv[]) {Mat image= Imread ("lena.bmp"); Mat grayimg; Cvtcolor (image, Grayimg, Cv_rgb2gray); Imshow ("Image1", image); Imshow ("grayimg", grayimg); Waitkey (6000); return 0; }
OPENCV2 Learning--the basic operation of images