Advertisement
Guest User

Untitled

a guest
Feb 18th, 2020
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.76 KB | None | 0 0
  1.  
  2. #include <opencv2/opencv.hpp>
  3. #include <opencv2/imgproc/imgproc.hpp>
  4. #include <opencv2/core/core.hpp>
  5. #include <opencv2/highgui/highgui.hpp>
  6. #include <iostream>
  7. #include<stdio.h>
  8. using namespace cv;
  9. using namespace std;
  10.  
  11.  
  12.  
  13. int DELAY_CAPTION = 1500;
  14. int DELAY_BLUR = 100;
  15. int MAX_KERNEL_LENGTH = 31;
  16. Mat source; Mat dst;
  17. char window_name[] = "Les 4 type";
  18. int display_dst( int delay );
  19.  
  20. int main(){///int argc, char** argv )
  21.  
  22.     //*********Question 1***********
  23.      Mat imGray=imread("im.jpg",1);  //Mat source; source = imread(argv[1], CV_LOAD_IMAGE_COLOR);
  24.     // affichage
  25.  
  26.      cvtColor(imGray, source, CV_BGR2GRAY);
  27.  
  28.     namedWindow("image source", WINDOW_AUTOSIZE);
  29.     imshow("image source", source);
  30.  
  31.     for ( int i = 1; i < MAX_KERNEL_LENGTH; i = i + 2 )
  32.         {
  33.             blur( source, dst, Size( i, i ), Point(-1,-1) );
  34.             if( display_dst( DELAY_BLUR ) != 0 )
  35.             {
  36.                 return 0;
  37.             }
  38.         }
  39.  
  40.     for ( int i = 1; i < MAX_KERNEL_LENGTH; i = i + 2 )
  41.         {
  42.             GaussianBlur( source, dst, Size( i, i ), 0, 0 );
  43.             if( display_dst( DELAY_BLUR ) != 0 )
  44.             {
  45.                 return 0;
  46.             }
  47.         }
  48.  
  49.     for ( int i = 1; i < MAX_KERNEL_LENGTH; i = i + 2 )
  50.         {
  51.             medianBlur ( source, dst, i );
  52.             if( display_dst( DELAY_BLUR ) != 0 )
  53.             {
  54.                 return 0;
  55.             }
  56.         }
  57.  
  58.      for ( int i = 1; i < MAX_KERNEL_LENGTH; i = i + 2 )
  59.         {
  60.             bilateralFilter ( source, dst, i, i*2, i/2 );
  61.             if( display_dst( DELAY_BLUR ) != 0 )
  62.             {
  63.                 return 0;
  64.             }
  65.         }
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.       waitKey(0);
  74.  
  75.       return 0;
  76.     }
  77.  
  78. int display_dst( int delay )
  79. {
  80.     imshow( window_name, dst );
  81.     int c = waitKey ( delay );
  82.     if( c >= 0 ) { return -1; }
  83.     return 0;
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement