像素积分图计算:
1 #include <opencv2/opencv.hpp> 2 #include <iostream> 3 4 using namespace cv; 5 6 int main(int argc, char** argv) { 7 Mat src = imread("L:/5.jpg", IMREAD_GRAYSCALE); 8 if (src.empty()) { 9 printf("could not load image... "); 10 return -1; 11 } 12 namedWindow("input image", CV_WINDOW_AUTOSIZE); 13 imshow("input image", src); 14 15 Mat sumii = Mat::zeros(src.rows + 1, src.cols + 1, CV_32FC1); //参数1.左上角像素和 16 Mat sqsumii = Mat::zeros(src.rows + 1, src.cols + 1, CV_64FC1);//参数2.左上角像素平方和 17 integral(src, sumii, sqsumii); //积分算法API 18 19 Mat iiResult; 20 normalize(sumii, iiResult, 0, 255, NORM_MINMAX, CV_8UC1, Mat());// 归一化 21 imshow("Integral Image", iiResult); 22 23 waitKey(0); 24 return 0; 25 }