当前位置:   article > 正文

[OpenCV4] 湖南大学数字图像处理实验1

[OpenCV4] 湖南大学数字图像处理实验1

实验1目录

实验内容

运行效果

项目源码

1 Sources

1.1 main.cpp:

1.2 readImg.cpp

1.3 readVideo.cpp

1.4  imgprocess.cpp

1.5 functrans.cpp

1.6 drawhistogram.cpp

1.7  histogramselfimplementation.cpp

2. Headers

2.1 main.h

2.2 readimg.h

2.3 readvideo.h

2.4 imgprocess.h

2.5 functrans.h

2.6 drawhistogram.h

2.7 histogramselfimplementation.h


实验内容

1.安装 opencv

2.opencv打开图片视频

3.opencv对图像进行加减乘取反

4.opencv使用点运算,进行各种函数的处理

5.直方图生成 (使用 opencv 库函数 & 自己实现)

运行效果

readimg:

readvideo:

imgadd:

img2:

1/2 img + 1/2 img2

img1 -img2

 img1 * img2

reversed img

Histogram Library Implementation

Histogram Self Implementation

 

项目源码

1 Sources

1.1 main.cpp:

  1. /**
  2. * author : CHENHANXUAN
  3. * class : m1701
  4. * id : 201726010211
  5. */
  6. #include "main.h"
  7. int main(int argc, char** argv) {
  8. // Self Histogram implementation
  9. selfDrawHistogram();
  10. // Read images
  11. imageReader(argc, argv);
  12. // Read videos
  13. videoReader(argc, argv);
  14. // Image add operation
  15. imageAdd();
  16. // Image subduce operation
  17. imageSub();
  18. // Image multiply operation
  19. imageMul();
  20. // Image reverse operation
  21. imageRev();
  22. // Function implementation - exponent
  23. expTransform();
  24. // OpenCV histogram generation
  25. drawHistogram();
  26. return 0;
  27. }

1.2 readImg.cpp

  1. #include "readImg.h"
  2. void imageReader(int argc, char** argv) {
  3. String img_name = "../media/orange_peel.jpeg";
  4. // Arguments detection
  5. if (argc < 3) {
  6. cout << "Usage: " << argv[0] << " pic_path [G]" << endl;
  7. cout << "Hint : [] means optional for grayscale" << endl;
  8. cout << "Now use default img at '../media/orange.jpeg' " << endl;
  9. }
  10. else {
  11. img_name = argv[1];
  12. }
  13. // Read img
  14. Mat source_img;
  15. if (argc >= 3) {
  16. // Read image in grayscale
  17. source_img = imread(img_name, IMREAD_GRAYSCALE);
  18. }
  19. else {
  20. // Read the image in RGB format
  21. source_img = imread(img_name, IMREAD_COLOR);
  22. }
  23. if (!source_img.empty()) {
  24. namedWindow("ORIGINAL IMG", WINDOW_AUTOSIZE);
  25. imshow("ORIGINAL IMG", source_img);
  26. }
  27. waitKey();
  28. }

1.3 readVideo.cpp

  1. #include "readvideo.h"
  2. static void help()
  3. {
  4. cout
  5. << "------------------------------------------------------------------------------" << endl
  6. << "This program shows how to read a video file with OpenCV. In addition, it "
  7. << "tests the similarity of two input videos first with PSNR, and for the frames "
  8. << "below a PSNR trigger value, also with MSSIM." << endl
  9. << "Usage:" << endl
  10. << "./video-input-psnr-ssim <referenceVideo> <useCaseTestVideo> <PSNR_Trigger_Value> <Wait_Between_Frames> " << endl
  11. << "--------------------------------------------------------------------------" << endl
  12. << endl;
  13. }
  14. int videoReader(int argc, char **argv)
  15. {
  16. help();
  17. stringstream conv;
  18. int psnrTriggerValue, delay;
  19. string sourceReference, sourceCompareWith;
  20. if (argc != 5)
  21. {
  22. sourceReference = "/home/chenhanxuan/QtProjects/media/videos/Megamind.avi";
  23. sourceCompareWith = "/home/chenhanxuan/QtProjects/media/videos/Megamind_bugy.avi";
  24. psnrTriggerValue = 35;
  25. delay = 10;
  26. cout << "Not enough parameters" << endl;
  27. cout << "Now use the default video clips" << endl;
  28. cout << "Use default PSNR_Trigger_Value = 35" << endl;
  29. cout << "Use default Wait_Between_Frame = 10" << endl;
  30. }
  31. else {
  32. // Use the parameters caught from main function
  33. sourceReference = argv[1], sourceCompareWith = argv[2];
  34. conv << argv[3] << endl << argv[4]; // put in the strings
  35. conv >> psnrTriggerValue >> delay; // take out the numbers
  36. }
  37. int frameNum = -1; // Frame counter
  38. VideoCapture captRefrnc(sourceReference), captUndTst(sourceCompareWith);
  39. if (!captRefrnc.isOpened())
  40. {
  41. cout << "Could not open reference " << sourceReference << endl;
  42. return -1;
  43. }
  44. if (!captUndTst.isOpened())
  45. {
  46. cout << "Could not open case test " << sourceCompareWith << endl;
  47. return -1;
  48. }
  49. Size refS = Size((int)captRefrnc.get(CAP_PROP_FRAME_WIDTH),
  50. (int)captRefrnc.get(CAP_PROP_FRAME_HEIGHT)),
  51. uTSi = Size((int)captUndTst.get(CAP_PROP_FRAME_WIDTH),
  52. (int)captUndTst.get(CAP_PROP_FRAME_HEIGHT));
  53. if (refS != uTSi)
  54. {
  55. cout << "Inputs have different size!!! Closing." << endl;
  56. return -1;
  57. }
  58. const char* WIN_UT = "Under Test";
  59. const char* WIN_RF = "Reference";
  60. // Windows
  61. namedWindow(WIN_RF, WINDOW_AUTOSIZE);
  62. namedWindow(WIN_UT, WINDOW_AUTOSIZE);
  63. moveWindow(WIN_RF, 400, 0); //750, 2 (bernat =0)
  64. moveWindow(WIN_UT, refS.width, 0); //1500, 2
  65. cout << "Reference frame resolution: Width=" << refS.width << " Height=" << refS.height
  66. << " of nr#: " << captRefrnc.get(CAP_PROP_FRAME_COUNT) << endl;
  67. cout << "PSNR trigger value " << setiosflags(ios::fixed) << setprecision(3)
  68. << psnrTriggerValue << endl;
  69. Mat frameReference, frameUnderTest;
  70. double psnrV;
  71. Scalar mssimV;
  72. for (;;) //Show the image captured in the window and repeat
  73. {
  74. captRefrnc >> frameReference;
  75. captUndTst >> frameUnderTest;
  76. if (frameReference.empty() || frameUnderTest.empty())
  77. {
  78. cout << " < < < Game over! > > > ";
  79. break;
  80. }
  81. ++frameNum;
  82. cout << "Frame: " << frameNum << "# ";
  83. psnrV = getPSNR(frameReference, frameUnderTest);
  84. cout << setiosflags(ios::fixed) << setprecision(3) << psnrV << "dB";
  85. if (psnrV < psnrTriggerValue && psnrV)
  86. {
  87. mssimV = getMSSIM(frameReference, frameUnderTest);
  88. cout << " MSSIM: "
  89. << " R " << setiosflags(ios::fixed) << setprecision(2) << mssimV.val[2] * 100 << "%"
  90. << " G " << setiosflags(ios::fixed) << setprecision(2) << mssimV.val[1] * 100 << "%"
  91. << " B " << setiosflags(ios::fixed) << setprecision(2) << mssimV.val[0] * 100 << "%";
  92. }
  93. cout << endl;
  94. imshow(WIN_RF, frameReference);
  95. imshow(WIN_UT, frameUnderTest);
  96. char c = (char)waitKey(delay);
  97. if (c == 27) break;
  98. }
  99. waitKey();
  100. return 0;
  101. }
  102. double getPSNR(const Mat& I1, const Mat& I2)
  103. {
  104. Mat s1;
  105. absdiff(I1, I2, s1); // |I1 - I2|
  106. s1.convertTo(s1, CV_32F); // cannot make a square on 8 bits
  107. s1 = s1.mul(s1); // |I1 - I2|^2
  108. Scalar s = sum(s1); // sum elements per channel
  109. double sse = s.val[0] + s.val[1] + s.val[2]; // sum channels
  110. if (sse <= 1e-10) // for small values return zero
  111. return 0;
  112. else
  113. {
  114. double mse = sse / (double)(I1.channels() * I1.total());
  115. double psnr = 10.0 * log10((255 * 255) / mse);
  116. return psnr;
  117. }
  118. }
  119. Scalar getMSSIM(const Mat& i1, const Mat& i2)
  120. {
  121. const double C1 = 6.5025, C2 = 58.5225;
  122. /***************************** INITS **********************************/
  123. int d = CV_32F;
  124. Mat I1, I2;
  125. i1.convertTo(I1, d); // cannot calculate on one byte large values
  126. i2.convertTo(I2, d);
  127. Mat I2_2 = I2.mul(I2); // I2^2
  128. Mat I1_2 = I1.mul(I1); // I1^2
  129. Mat I1_I2 = I1.mul(I2); // I1 * I2
  130. /*************************** END INITS **********************************/
  131. Mat mu1, mu2; // PRELIMINARY COMPUTING
  132. GaussianBlur(I1, mu1, Size(11, 11), 1.5);
  133. GaussianBlur(I2, mu2, Size(11, 11), 1.5);
  134. Mat mu1_2 = mu1.mul(mu1);
  135. Mat mu2_2 = mu2.mul(mu2);
  136. Mat mu1_mu2 = mu1.mul(mu2);
  137. Mat sigma1_2, sigma2_2, sigma12;
  138. GaussianBlur(I1_2, sigma1_2, Size(11, 11), 1.5);
  139. sigma1_2 -= mu1_2;
  140. GaussianBlur(I2_2, sigma2_2, Size(11, 11), 1.5);
  141. sigma2_2 -= mu2_2;
  142. GaussianBlur(I1_I2, sigma12, Size(11, 11), 1.5);
  143. sigma12 -= mu1_mu2;
  144. Mat t1, t2, t3;
  145. t1 = 2 * mu1_mu2 + C1;
  146. t2 = 2 * sigma12 + C2;
  147. t3 = t1.mul(t2); // t3 = ((2*mu1_mu2 + C1).*(2*sigma12 + C2))
  148. t1 = mu1_2 + mu2_2 + C1;
  149. t2 = sigma1_2 + sigma2_2 + C2;
  150. t1 = t1.mul(t2); // t1 =((mu1_2 + mu2_2 + C1).*(sigma1_2 + sigma2_2 + C2))
  151. Mat ssim_map;
  152. divide(t3, t1, ssim_map); // ssim_map = t3./t1;
  153. Scalar mssim = mean(ssim_map); // mssim = average of ssim map
  154. return mssim;
  155. }

1.4  imgprocess.cpp

  1. #include "imgprocess.h"
  2. // Use default imgs here to do calculation
  3. const static String dir2 = "../media/desktop1.png";
  4. const static String dir1 = "../media/desktop2.png";
  5. // Use addWeighted() to solve the add and sub
  6. void imageAdd() {
  7. Mat img1 = imread(dir1, IMREAD_COLOR);
  8. Mat img2 = imread(dir2, IMREAD_COLOR);
  9. Mat dst;
  10. double alpha = 0.5; double beta = 1.0 - alpha;
  11. addWeighted( img1, alpha, img2, beta, 0.0, dst);
  12. imshow("IMG1", img1);
  13. imshow("IMG2", img2);
  14. imshow( "1/2 * IMG1 + 1 / 2 * IMG2", dst );
  15. waitKey(0);
  16. }
  17. void imageSub() {
  18. Mat img1 = imread(dir1, IMREAD_COLOR);
  19. Mat img2 = imread(dir2, IMREAD_COLOR);
  20. Mat dst;
  21. double alpha = 1; double beta = -1;
  22. addWeighted( img1, alpha, img2, beta, 0.0, dst);
  23. imshow("img1", img1);
  24. imshow("img2", img2);
  25. imshow( "IMG1 - IMG2", dst );
  26. waitKey(0);
  27. }
  28. void init_lookup_table(uchar* lookup_table) {
  29. for (int i = 0 ; i < 256 ; ++i) {
  30. lookup_table[i] = 255 - i;
  31. }
  32. }
  33. Mat& applyTableRev(Mat& I, const uchar* const table) {
  34. CV_Assert(I.depth() == CV_8U);
  35. uchar *p_row = NULL; // Start position of the row
  36. int nRow = I.rows;
  37. int nCol = I.cols * I.channels();
  38. if (I.isContinuous()) {
  39. nCol *= nRow;
  40. nRow = 1;
  41. }
  42. for (int i = 0 ; i < nRow ; ++i) {
  43. p_row = I.ptr<uchar>(i);
  44. for (int j = 0 ; j < nCol ; ++j) {
  45. p_row[j] = table[p_row[j]];
  46. }
  47. }
  48. return I;
  49. }
  50. Mat& applyMul(Mat& I, Mat& J, Mat& dst) {
  51. CV_Assert(I.depth() == CV_8U);
  52. const int channels = I.channels();
  53. switch (channels) {
  54. case 1 : {
  55. for (int i = 0 ; i < I.rows ; ++i) {
  56. for (int j = 0 ; j < I.cols ; ++j) {
  57. dst.at<uchar>(i, j) = (I.at<uchar> \
  58. (i, j) * J.at<uchar>(i, j)) % 256;
  59. }
  60. }
  61. break;
  62. }
  63. case 3 : {
  64. Mat_<Vec3b> _dst = dst;
  65. Mat_<Vec3b> _I = I, _J = J;
  66. for (int i = 0 ; i < I.rows ; ++i) {
  67. for (int j = 0 ; j < I.cols ; ++j) {
  68. _dst(i, j)[0] = (_I(i, j)[0] * \
  69. _J(i, j)[0]) % 256;
  70. _dst(i, j)[1] = (_I(i, j)[1] * \
  71. _J(i, j)[1]) % 256;
  72. _dst(i, j)[2] = (_I(i, j)[2] * \
  73. _J(i, j)[2]) % 256;
  74. }
  75. }
  76. dst = _dst;
  77. break;
  78. }
  79. }
  80. return dst;
  81. }
  82. void imageRev() {
  83. uchar lookup_table[256];
  84. init_lookup_table(lookup_table);
  85. Mat src = imread(dir1, IMREAD_COLOR);
  86. Mat dst = src.clone();
  87. applyTableRev(dst, lookup_table);
  88. imshow("ORIGIN IMG", src);
  89. imshow("REVERSED IMG", dst);
  90. waitKey(0);
  91. }
  92. void imageMul() {
  93. uchar lookup_table[256];
  94. init_lookup_table(lookup_table);
  95. Mat img1 = imread(dir1, IMREAD_COLOR);
  96. Mat img2 = imread(dir2, IMREAD_COLOR);
  97. Mat dst(img1.size(), img1.type());
  98. applyMul(img1, img2, dst);
  99. imshow("IMG1", img1);
  100. imshow("IMG2", img2);
  101. imshow("IMG1 * IMG2", dst);
  102. waitKey(0);
  103. }

1.5 functrans.cpp

  1. #include "functrans.h"
  2. static void init_lookup_table(uchar* lookup_table) {
  3. double c = 0.8;
  4. int r = 2;
  5. for (int i = 0 ; i < 256 ; ++i) {
  6. lookup_table[i] = int((c * pow((lookup_table[i])/255.0, r)) * 255 + 0.5);
  7. }
  8. }
  9. Mat& applyExp(Mat& I, const uchar* const table) {
  10. CV_Assert(I.depth() == CV_8U);
  11. uchar *p_row = NULL; // Start position of the row
  12. int nRow = I.rows;
  13. int nCol = I.cols * I.channels();
  14. if (I.isContinuous()) {
  15. nCol *= nRow;
  16. nRow = 1;
  17. }
  18. for (int i = 0 ; i < nRow ; ++i) {
  19. p_row = I.ptr<uchar>(i);
  20. for (int j = 0 ; j < nCol ; ++j) {
  21. p_row[j] = table[p_row[j]];
  22. }
  23. }
  24. return I;
  25. }
  26. void expTransform() {
  27. uchar lookup_table[256];
  28. init_lookup_table(lookup_table);
  29. const static String dir1 = "../media/desktop2.png";
  30. Mat src = imread(dir1, IMREAD_COLOR);
  31. Mat dst = src.clone();
  32. applyExp(dst, lookup_table);
  33. imshow("ORIGIN IMG", src);
  34. imshow("Exp IMG", dst);
  35. waitKey(0);
  36. }

1.6 drawhistogram.cpp

  1. #include "drawhistogram.h"
  2. void drawHistogram() {
  3. String dir = "../media/orange_peel.jpeg";
  4. Mat src = imread(dir, IMREAD_COLOR);
  5. vector<Mat> bgr_planes;
  6. split( src, bgr_planes );
  7. int histSize = 256;
  8. float range[] = { 0, 256 }; //the upper boundary is exclusive
  9. const float* histRange = { range };
  10. bool uniform = true, accumulate = false;
  11. Mat b_hist, g_hist, r_hist;
  12. calcHist( &bgr_planes[0], 1, 0, Mat(), b_hist, 1, &histSize, &histRange, uniform, accumulate );
  13. calcHist( &bgr_planes[1], 1, 0, Mat(), g_hist, 1, &histSize, &histRange, uniform, accumulate );
  14. calcHist( &bgr_planes[2], 1, 0, Mat(), r_hist, 1, &histSize, &histRange, uniform, accumulate );
  15. int hist_w = 512, hist_h = 400;
  16. int bin_w = cvRound( (double) hist_w/histSize );
  17. Mat histImage( hist_h, hist_w, CV_8UC3, Scalar( 0,0,0) );
  18. normalize(b_hist, b_hist, 0, histImage.rows, NORM_MINMAX, -1, Mat() );
  19. normalize(g_hist, g_hist, 0, histImage.rows, NORM_MINMAX, -1, Mat() );
  20. normalize(r_hist, r_hist, 0, histImage.rows, NORM_MINMAX, -1, Mat() );
  21. for( int i = 1; i < histSize; i++ )
  22. {
  23. line( histImage, Point( bin_w*(i-1), hist_h - cvRound(b_hist.at<float>(i-1)) ),
  24. Point( bin_w*(i), hist_h - cvRound(b_hist.at<float>(i)) ),
  25. Scalar( 255, 0, 0), 2, 8, 0 );
  26. line( histImage, Point( bin_w*(i-1), hist_h - cvRound(g_hist.at<float>(i-1)) ),
  27. Point( bin_w*(i), hist_h - cvRound(g_hist.at<float>(i)) ),
  28. Scalar( 0, 255, 0), 2, 8, 0 );
  29. line( histImage, Point( bin_w*(i-1), hist_h - cvRound(r_hist.at<float>(i-1)) ),
  30. Point( bin_w*(i), hist_h - cvRound(r_hist.at<float>(i)) ),
  31. Scalar( 0, 0, 255), 2, 8, 0 );
  32. }
  33. imshow("Source image", src );
  34. imshow("calcHist Demo", histImage );
  35. waitKey();
  36. }

1.7  histogramselfimplementation.cpp

  1. #include "histogramselfimplementation.h"
  2. #define DEBUG
  3. // Draw histogram without calling the opencv function "calHist"
  4. // Through img scanning and implement own way
  5. void selfDrawHistogram() {
  6. String dir = "../media/orange_peel.jpeg";
  7. Mat I = imread(dir, IMREAD_COLOR);
  8. if (I.empty()) {
  9. std :: cout << "Error open Img" << std :: endl;
  10. exit(0);
  11. }
  12. // Get the size of the Img
  13. int max_b = 0;
  14. int max_g = 0;
  15. int max_r = 0;
  16. // Declear the different color intensity value
  17. int histSize = 256;
  18. // Prepare the container (256 for 256 different intensity)
  19. float b_hist[256], g_hist[256], r_hist[256];
  20. memset(b_hist, 0, sizeof(b_hist));
  21. memset(g_hist, 0, sizeof(g_hist));
  22. memset(r_hist, 0, sizeof(r_hist));
  23. // Count the frequency of apperance times of each intensity
  24. MatIterator_<Vec3b> it, end;
  25. for (it = I.begin<Vec3b>(), end = I.end<Vec3b>() ; it != end ; ++it) {
  26. b_hist[(*it)[0]]++;
  27. g_hist[(*it)[1]]++;
  28. r_hist[(*it)[2]]++;
  29. }
  30. // Manually normalize
  31. for (int i = 0 ; i < 256 ; i++) {
  32. max_b = max_b < b_hist[i] ? b_hist[i] : max_b;
  33. max_g = max_g < g_hist[i] ? g_hist[i] : max_g;
  34. max_r = max_r < r_hist[i] ? r_hist[i] : max_r;
  35. }
  36. #ifdef DEBUG
  37. for (int i = 0 ; i < 256 ; i++) {
  38. std :: cout << "b_hist[i] = " << b_hist[i] << std :: endl;
  39. std :: cout << "g_hist[i] = " << g_hist[i] << std :: endl;
  40. std :: cout << "r_hist[i] = " << r_hist[i] << std :: endl;
  41. }
  42. #endif
  43. // Set the width and the height of the canvas
  44. int hist_w = 512, hist_h = 400;
  45. int bin_w = cvRound( (double) hist_w / histSize );
  46. Mat histImage( hist_h, hist_w, CV_8UC3, Scalar( 0, 0, 0 ) );
  47. #ifdef DEBUG
  48. std :: cout << "hist_w = " << hist_w << "hist_h = " << hist_h << std :: endl;
  49. std :: cout << "bin_w = " << bin_w << std :: endl;
  50. #endif
  51. // Normalize the height and width manually
  52. int reduced_height = int(hist_h * 0.9);
  53. for ( int i = 1 ; i < 256 ; i++ ) {
  54. b_hist[i] = ( b_hist[i] / max_b ) * reduced_height;
  55. g_hist[i] = ( g_hist[i] / max_g ) * reduced_height;
  56. r_hist[i] = ( r_hist[i] / max_r ) * reduced_height;
  57. }
  58. #ifdef DEBUG
  59. for ( int i = 0 ; i < 256 ; i++ ) {
  60. std :: cout << "b_hist[i] = " << b_hist[i] << std :: endl;
  61. std :: cout << "g_hist[i] = " << g_hist[i] << std :: endl;
  62. std :: cout << "r_hist[i] = " << r_hist[i] << std :: endl;
  63. }
  64. std :: cout << "" << std :: endl;
  65. waitKey();
  66. #endif
  67. for( int i = 1; i < histSize; i++ )
  68. {
  69. line( histImage, Point( bin_w * (i-1), b_hist[i-1]),
  70. Point( bin_w * (i), b_hist[i]) ,
  71. Scalar( 255, 0, 0), 2, 8, 0 );
  72. line( histImage, Point( bin_w * (i-1), g_hist[i-1]),
  73. Point( bin_w * (i), g_hist[i]),
  74. Scalar( 0, 255, 0), 2, 8, 0 );
  75. line( histImage, Point( bin_w * (i-1), r_hist[i-1]),
  76. Point( bin_w * (i), r_hist[i]),
  77. Scalar( 0, 0, 255), 2, 8, 0 );
  78. }
  79. imshow("Source image", I );
  80. imshow("Self Histogram Implementation", histImage );
  81. waitKey();
  82. }

2. Headers

2.1 main.h

  1. #ifndef MAIN_H
  2. #define MAIN_H
  3. // This experiment use the following macros (#)
  4. #include "readImg.h"
  5. #include "readvideo.h"
  6. #include "imgprocess.h"
  7. #include "functrans.h"
  8. #include "drawhistogram.h"
  9. #include "histogramselfimplementation.h"
  10. // This experiment use the following aliases (typedef)
  11. // This experiment has following function definition
  12. void read_img();
  13. #endif // MAIN_H

2.2 readimg.h

  1. #ifndef MAIN_H
  2. #define MAIN_H
  3. // This experiment use the following macros (#)
  4. #include "readImg.h"
  5. #include "readvideo.h"
  6. #include "imgprocess.h"
  7. #include "functrans.h"
  8. #include "drawhistogram.h"
  9. #include "histogramselfimplementation.h"
  10. // This experiment use the following aliases (typedef)
  11. // This experiment has following function definition
  12. void read_img();
  13. #endif // MAIN_H

2.3 readvideo.h

  1. #ifndef READVIDEO_H
  2. #define READVIDEO_H
  3. #include <iostream> // for standard I/O
  4. #include <string> // for strings
  5. #include <iomanip> // for controlling float print precision
  6. #include <sstream> // string to number conversion
  7. #include <opencv2/opencv.hpp>
  8. using namespace std;
  9. using namespace cv;
  10. double getPSNR(const Mat& I1, const Mat& I2);
  11. Scalar getMSSIM(const Mat& I1, const Mat& I2);
  12. int videoReader(int argc, char **argv);
  13. #endif // READVIDEO_H

2.4 imgprocess.h

  1. #ifndef IMGPROCESS_H
  2. #define IMGPROCESS_H
  3. #include <opencv2/opencv.hpp>
  4. using namespace cv;
  5. void imageAdd();
  6. void imageSub();
  7. void imageMul();
  8. void imageRev();
  9. #endif // IMGPROCESS_H

2.5 functrans.h

  1. // Function transformations
  2. #ifndef FUNCTRANS_H
  3. #define FUNCTRANS_H
  4. #include <cmath>
  5. #include <opencv2/opencv.hpp>
  6. using namespace cv;
  7. void expTransform();
  8. #endif // FUNCTRANS_H

2.6 drawhistogram.h

  1. #ifndef DRAWHISTOGRAM_H
  2. #define DRAWHISTOGRAM_H
  3. #include <opencv2/opencv.hpp>
  4. #include <iostream>
  5. #include <vector>
  6. using namespace std;
  7. using namespace cv;
  8. void drawHistogram();
  9. #endif // DRAWHISTOGRAM_H

2.7 histogramselfimplementation.h

  1. #ifndef HISTOGRAMSELFIMPLEMENTATION_H
  2. #define HISTOGRAMSELFIMPLEMENTATION_H
  3. #include <opencv2/opencv.hpp>
  4. using namespace cv;
  5. void selfDrawHistogram();
  6. #endif // HISTOGRAMSELFIMPLEMENTATION_H

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小小林熬夜学编程/article/detail/657386
推荐阅读
相关标签
  

闽ICP备14008679号