/opencv_extra/learning_opencv_v2/ch3_ex3_12.cpp

https://github.com/malcolmreynolds/OpenCV · C++ · 53 lines · 26 code · 2 blank · 25 comment · 4 complexity · 44f1350f2f2cfbdca7eb1a37b5a9a0a5 MD5 · raw file

  1. /* License:
  2. Oct. 3, 2008
  3. Right to use this code in any way you want without warrenty, support or any guarentee of it working.
  4. BOOK: It would be nice if you cited it:
  5. Learning OpenCV: Computer Vision with the OpenCV Library
  6. by Gary Bradski and Adrian Kaehler
  7. Published by O'Reilly Media, October 3, 2008
  8. AVAILABLE AT:
  9. http://www.amazon.com/Learning-OpenCV-Computer-Vision-Library/dp/0596516134
  10. Or: http://oreilly.com/catalog/9780596516130/
  11. ISBN-10: 0596516134 or: ISBN-13: 978-0596516130
  12. OTHER OPENCV SITES:
  13. * The source code is on sourceforge at:
  14. http://sourceforge.net/projects/opencvlibrary/
  15. * The OpenCV wiki page (As of Oct 1, 2008 this is down for changing over servers, but should come back):
  16. http://opencvlibrary.sourceforge.net/
  17. * An active user group is at:
  18. http://tech.groups.yahoo.com/group/OpenCV/
  19. * The minutes of weekly OpenCV development meetings are at:
  20. http://pr.willowgarage.com/wiki/OpenCV
  21. */
  22. #include <cv.h>
  23. #include <highgui.h>
  24. // ch3_ex3_12 image_name x y width height add#
  25. int main(int argc, char** argv)
  26. {
  27. IplImage* src;
  28. cvNamedWindow("Example3_12_pre", CV_WINDOW_AUTOSIZE);
  29. cvNamedWindow("Example3_12_post", CV_WINDOW_AUTOSIZE);
  30. if( argc == 7 && ((src=cvLoadImage(argv[1],1)) != 0 ))
  31. {
  32. int x = atoi(argv[2]);
  33. int y = atoi(argv[3]);
  34. int width = atoi(argv[4]);
  35. int height = atoi(argv[5]);
  36. int add = atoi(argv[6]);
  37. cvShowImage( "Example3_12_pre", src);
  38. cvSetImageROI(src, cvRect(x,y,width,height));
  39. cvAddS(src, cvScalar(add),src);
  40. cvResetImageROI(src);
  41. cvShowImage( "Example3_12_post",src);
  42. cvWaitKey();
  43. }
  44. cvReleaseImage( &src );
  45. cvDestroyWindow("Example3_12_pre");
  46. cvDestroyWindow("Example3_12_post");
  47. return 0;
  48. }