乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      簡單的圖像變換

       absolutely113 2013-07-19
      1)載入一副圖像并進行平滑處理

      #include "stdafx.h"
      #include "highgui.h"
      #include "cv.h"
      #include "cxcore.h"

      int main(int argc,char *argv[])
      {
            IplImage* src = cvLoadImage( "D:\\Demo.jpg");
            cvNamedWindow( "show_image");
            cvNamedWindow( "show_out");

            cvShowImage( "show_image",src);
            IplImage* out=cvCreateImage(cvGetSize(src),IPL_DEPTH_8U,3);
            cvSmooth(src,out,CV_GAUSSIAN,3,3);
            cvShowImage( "show_out",out);
                       
            cvWaitKey(0);
            cvReleaseImage(&src);
            cvReleaseImage(&out);
            cvDestroyWindow( "show_out");
            cvDestroyWindow( "show_image");
            return 0;

      }

      (2)使用cvPyrDown()創(chuàng)建一副寬度和高度為輸入圖像一半尺寸的圖像

      #include "stdafx.h"
      #include "highgui.h"
      #include "cv.h"
      #include "cxcore.h"

      IplImage* doPyrDown(IplImage* in, int filter = IPL_GAUSSIAN_5x5)
      {

          // Best to make sure input image is divisible by two.
          assert( in->width%2 == 0 && in->height%2 == 0 );

          IplImage* out = cvCreateImage(
              cvSize( in->width/2, in->height/2 ),
              in->depth,
              in->nChannels
          );
          cvPyrDown( in, out );
          return( out );
      };


      int main(int argc,char *argv[])
      {
            IplImage* src = cvLoadImage( "D:\\Demo.jpg");
                        IplImage* out = cvCreateImage( cvSize( src->width/2,src->height/2 ), src->depth, src->nChannels);
          
                        cvNamedWindow( "show_image");
                        cvNamedWindow( "show_out");

            cvShowImage( "show_image",src);
                       
                        out = doPyrDown( src );
                        cvShowImage( "show_out",out);
                       
            cvWaitKey(0);
            cvReleaseImage(&src);
                        cvReleaseImage(&out);
                        cvDestroyWindow( "show_out");
            cvDestroyWindow( "show_image");
            return 0;

      }

      (3)Canny邊緣檢測將輸出寫入一個單通道(灰度級)圖像


      #include "stdafx.h"
      #include "highgui.h"
      #include "cv.h"
      #include "cxcore.h"

      IplImage* doCanny(
          IplImage* in,
          double    lowThresh,
          double    highThresh,
          double    aperture)
      {
          if (in->nChannels != 1)
              return(0); // Canny only handles gray scale images
          IplImage* out = cvCreateImage(
              cvGetSize( in ),
              in->depth, //IPL_DEPTH_8U,   
              1);
          cvCanny( in, out, lowThresh, highThresh, aperture );
          return( out );
      };



      int main(int argc,char *argv[])
      {
            IplImage* src = cvLoadImage( "D:\\Demo.jpg");
                        IplImage* img_gry = cvCreateImage( cvSize( src->width,src->height ), src->depth, 1);
                        cvCvtColor(src, img_gry ,CV_BGR2GRAY);

                        cvNamedWindow( "show_gray");
                        cvNamedWindow( "show_canny");

            cvShowImage( "show_gray",img_gry);
                       
                        IplImage* img_cny = doCanny( img_gry, 10, 100, 3 );
                       
                        cvShowImage( "show_canny",img_cny);
                       
            cvWaitKey(0);
            cvReleaseImage(&src);
                        cvReleaseImage(&img_gry);
                        cvReleaseImage(&img_cny);
                        cvDestroyWindow( "show_gray");
            cvDestroyWindow( "show_canny");
            return 0;

      }

      (4)讀取一個視頻文件,將每一幀圖像轉(zhuǎn)換為對數(shù)極坐標(biāo)格式(就像你的眼鏡真正看到的),最后將轉(zhuǎn)換后的圖像序列寫入新的視頻文件中


      #include "stdafx.h"
      #include "highgui.h"
      #include "cv.h"
      #include "cxcore.h"
      #include <stdio.h>

      // Convert a video to grayscale
      // argv[1]: input video file
      // argv[2]: name of new output file
      //

      //#define NOWRITE 1;   //Turn this on (removed the first comment out "http://" if you can't write on linux

      int main( int argc, char* argv[] ) {
                      cvNamedWindow( "Example2_10", CV_WINDOW_AUTOSIZE );
                      cvNamedWindow( "Log_Polar", CV_WINDOW_AUTOSIZE );
                      CvCapture* capture = cvCreateFileCapture(  "D:\\sample.avi" );
                       if (!capture){
                                       return -1;
                      }
                      IplImage* bgr_frame;
                       double fps = cvGetCaptureProperty (
                                      capture,
                                      CV_CAP_PROP_FPS
                                      );
                      printf( "fps=%d\n",(int )fps);

                      CvSize size = cvSize(
                                      ( int)cvGetCaptureProperty( capture, CV_CAP_PROP_FRAME_WIDTH),
                                      ( int)cvGetCaptureProperty( capture, CV_CAP_PROP_FRAME_HEIGHT)
                                      );

                      printf( "frame (w, h) = (%d, %d)\n" ,size.width,size.height);
      #ifndef NOWRITE
                      CvVideoWriter* writer = cvCreateVideoWriter(  // On linux Will only work if you've installed ffmpeg development files correctly,
                                       "D:\\sampleout.avi"                              // otherwise segmentation fault.  Windows probably better.
                                      CV_FOURCC( 'M','J' ,'P', 'G'),   
                                      fps,
                                      size
                                      );
      #endif
                      IplImage* logpolar_frame = cvCreateImage(
                                      size,
                                      IPL_DEPTH_8U,
                                      3
                                      );

                      IplImage* gray_frame = cvCreateImage(
                                      size,
                                      IPL_DEPTH_8U,
                                      1
                                      );

                       while( (bgr_frame=cvQueryFrame(capture)) != NULL ) {
                                      cvShowImage( "Example2_10", bgr_frame );
                                      cvConvertImage(   //We never make use of this gray image
                                                      bgr_frame,
                                                      gray_frame,
                                                      CV_RGB2GRAY
                                                      );
                                      cvLogPolar( bgr_frame, logpolar_frame,  //This is just a fun conversion the mimic's the human visual system
                                                      cvPoint2D32f(bgr_frame->width/2,
                                                      bgr_frame->height/2),
                                                      40,
                                                      CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS );
                                      cvShowImage( "Log_Polar", logpolar_frame );
                                       //Sigh, on linux, depending on your ffmpeg, this often won't work ...
      #ifndef NOWRITE
                                      cvWriteToAVI( writer, logpolar_frame );
      #endif
                                       char c = cvWaitKey(10);
                                       if( c == 27 ) break ;
                      }
      #ifndef NOWRITE
                      cvReleaseVideoWriter( &writer );
      #endif
                      cvReleaseImage( &gray_frame );
                      cvReleaseImage( &logpolar_frame );
                      cvReleaseCapture( &capture );
      }

        本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報。
        轉(zhuǎn)藏 分享 獻花(0

        0條評論

        發(fā)表

        請遵守用戶 評論公約

        類似文章 更多