Advertisement
Guest User

Untitled

a guest
Dec 8th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. #include "cv.h"
  2. #include "highgui.h"
  3. IplImage* doCanny(
  4. IplImage* in,
  5. double lowThresh,
  6. double highThresh,
  7. double aperture)
  8. {
  9. IplImage* out = cvCreateImage(
  10. cvGetSize( in ),
  11. in->depth, //IPL_DEPTH_8U,
  12. 1);
  13. cvCanny( in, out, lowThresh, highThresh, aperture );
  14. return( out );
  15. }
  16. IplImage* doPyrDown(
  17. IplImage* in,
  18. int filter = IPL_GAUSSIAN_5x5)
  19. {
  20. // Best to make sure input image is divisible by two.
  21. //
  22. assert( in->width%2 == 0 && in->height%2 == 0 );
  23. IplImage* out = cvCreateImage(
  24. cvSize( in->width/2, in->height/2 ),
  25. in->depth,
  26. in->nChannels
  27. );
  28. cvPyrDown( in, out );
  29. return( out );
  30. };
  31. int main( int argc, char** argv )
  32. {
  33. cvNamedWindow("Example Gray", CV_WINDOW_AUTOSIZE );
  34. cvNamedWindow("Example Pyr", CV_WINDOW_AUTOSIZE );
  35. cvNamedWindow("Example Canny", CV_WINDOW_AUTOSIZE );
  36. IplImage* img_rgb = cvLoadImage("building.jpg" );
  37. IplImage* out;
  38. out = cvCreateImage( cvSize( img_rgb->width,img_rgb->height ), img_rgb->depth, 1);
  39. cvCvtColor(img_rgb, out ,CV_BGR2GRAY);
  40. cvShowImage("Example Gray", out );
  41. out = doPyrDown( out );
  42. out = doPyrDown( out );
  43. cvShowImage("Example Pyr", out );
  44. out = doCanny( out, 10, 100, 3 );
  45. cvShowImage("Example Canny", out );
  46. cvWaitKey(0);
  47. cvReleaseImage( &out);
  48. cvDestroyWindow("Example Gray");
  49. cvDestroyWindow("Example Pyr");
  50. cvDestroyWindow("Example Canny");
  51. } cvShowImage("Example Pyr", out );
  52. out = doCanny( out, 10, 100, 3 );
  53. cvShowImage("Example Canny", out );
  54. cvWaitKey(0);
  55. cvReleaseImage( &out);
  56. cvDestroyWindow("Example Gray");
  57. cvDestroyWindow("Example Pyr");
  58. cvDestroyWindow("Example Canny");
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement