程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> 關於C語言 >> 《學習OpenCV》練習題第四章第三題b

《學習OpenCV》練習題第四章第三題b

編輯:關於C語言

 #include <highgui.h>
 #include <cv.h>
 #include 
 
 
    
 
 
  
  draw = ;   
 
 IplImage* IplImage * IplImage * 
  draw_hist =  
 IplImage* getHistImage(IplImage* image, CvHistogram*       
     cvCalcHist( &image, image_hist,      
     IplImage* dst = cvCreateImage(image_size, IPL_DEPTH_8U,      
     cvSet( dst, cvScalarAll(     
      max_value =      cvGetMinMaxHistValue( image_hist, NULL, &      bin_width = ()dst->width/      bin_unith = ()dst->height/max_value;   
 
     ( i = ; i < ; i++          
         CvPoint p0 = cvPoint( i + bin_width, dst->         CvPoint p1 = cvPoint( (i+) *             dst->height - cvGetReal1D(image_hist->bins, i) *         
         cvRectangle( dst, p0, p1, value, -, ,   
       
  draw_rect(IplImage*            cvPoint( rect.x + rect.width, rect.y +         cvScalar( , ,      printf( 
          
      IplImage* src_rect =          img->depth, img->   
     IplImage* r_img =         src_rect->depth,      IplImage* g_img =         src_rect->depth,      IplImage* b_img =         src_rect->depth,      IplImage* gray_img =         src_rect->depth,      
     
      cvShowImage(      cvShowImage(      cvShowImage(      
     
       size =       range[] = {,      * ranges[] =     
     CvHistogram * r_hist = cvCreateHist( , &size, CV_HIST_ARRAY, ranges,      CvHistogram * g_hist = cvCreateHist( , &size, CV_HIST_ARRAY, ranges,      CvHistogram * b_hist = cvCreateHist( , &size, CV_HIST_ARRAY, ranges,      CvHistogram * gray_hist = cvCreateHist( , &size, CV_HIST_ARRAY, ranges,  
     
     CvSize image_size = cvSize( ,      
     IplImage* r_dst = getHistImage(r_img, r_hist, image_size, cvScalar(, ,      IplImage* g_dst = getHistImage(g_img, g_hist, image_size, cvScalar(, ,      IplImage* b_dst = getHistImage(b_img, b_hist, image_size, cvScalar(, ,      IplImage* gray_dst = getHistImage( gray_img, gray_hist, image_size, cvScalar( 
     
     IplImage* dst = cvCreateImage( cvSize( image_size.width * , image_size.height * ), ,       
     CvRect r_rect = cvRect( ,        
     CvRect g_rect = cvRect(image_size.width,        
     CvRect b_rect = cvRect(       
     CvRect gray_rect =    
  
     cvShowImage(      cvShowImage(  
     cvWaitKey( 
      cvReleaseImage( &     cvReleaseImage(&     cvReleaseImage(&     cvReleaseImage(&     cvReleaseImage(&     cvReleaseImage(&     cvReleaseImage(&     cvReleaseImage(&     cvReleaseImage(&     cvReleaseImage(&  
 
  my_mouse_callback(  ,  x,  y,  flags, *      IplImage* image = (IplImage* 
     (                                       rect.width = x -                 rect.height = y -  
             draw_hist =                              draw =              rect = cvRect( x, y, ,              draw_hist =                              draw =              draw_hist =              (rect.width <                   rect.x +=                 rect.width *= -              (rect.height <                   rect.y +=                 rect.height *= -              
                    
               printf(            
       img = cvLoadImage( ,  
     rect = cvRect( -, -, ,      
     
     temp =     original =     
     cvNamedWindow(     cvSetMouseCallback(, my_mouse_callback, (* 
     (   
             
         cvShowImage(  
         (cvWaitKey() ==                    cvReleaseImage(&     cvReleaseImage(&  
       }

運行結果:

 

不足:在源圖像上用鼠標選擇矩形區域的時候,無法實時地在圖像上反映出來。

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved