Guest User

Untitled

a guest
Jan 21st, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.77 KB | None | 0 0
  1. /* HISTOGRAM GENERATOR FOR 16BIT 1 CHANNEL GRAYSCALE PNG IMAGE */
  2.  
  3. #include "cv.h"
  4. #include "highgui.h"
  5. #include <stdio.h>
  6.  
  7.  
  8. void main(void)
  9. {
  10.     /* creates a window */
  11.     cvNamedWindow( "WINDOW", CV_WINDOW_AUTOSIZE );
  12.  
  13.     /* load the image */
  14.     IplImage *frame = cvLoadImage( "patternfile16bit.png", CV_LOAD_IMAGE_ANYDEPTH );
  15.  
  16.     /* print some properties */
  17.     printf( "# channels:  %d\n",        frame->nChannels );
  18.     printf( "Pixel depth: %d bits\n",   frame->depth );
  19.     printf( "width:       %d pixels\n", frame->width );
  20.     printf( "height:      %d pixels\n", frame->height );
  21.     printf( "Image size:  %d bytes\n",  frame->imageSize );
  22.     printf( "Width step:  %d bytes\n",  frame->widthStep );
  23.  
  24.     /* infinite loop */
  25.     while(1)
  26.     {
  27.         /* new image derived from the old one */
  28.         IplImage *frame2 = cvCreateImage(cvGetSize(frame),IPL_DEPTH_16U,1);
  29.  
  30.         /* show the old image */
  31.         cvShowImage( "WINDOW", frame );
  32.         /* show the derived one */
  33.         cvShowImage( "WINDOW", frame2 );
  34.         cvReleaseImage(&frame);
  35.         cvReleaseImage(&frame2);
  36.  
  37.         /*exit if ESC pressed */
  38.         if ( (cvWaitKey(10) & 255) == 27 ) break;
  39.     }
  40.     return(0);
  41.  }
  42.  
  43. ///// CONSOLE OUTPUT //////////////////////////////////////////////////////////////
  44.  
  45. # channels:  1
  46. Pixel depth: 16 bits
  47. width:       512 pixels
  48. height:      512 pixels
  49. Image size:  524288 bytes
  50. Width step:  1024 bytes
  51. OpenCV Error: Bad argument (Array should be CvMat or IplImage) in unknown functi
  52. on, file ..\..\..\..\ocv\opencv\src\cxcore\cxarray.cpp, line 1233
  53.  
  54. Process returned -529697949 (0xE06D7363)   execution time : 2.422 s
  55. Press any key to continue.
  56. ////// END OF CONSOLE OUTPUT ///////////////////////////////////////////////////////
Add Comment
Please, Sign In to add comment