/opencv_extra/learning_opencv_v2/ch3_ex3_11.cpp

https://github.com/malcolmreynolds/OpenCV · C++ · 53 lines · 24 code · 5 blank · 24 comment · 2 complexity · 69f46366c71a7e1491af9625912fc53e 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 <stdio.h>
  23. #include <cv.h>
  24. #include <highgui.h>
  25. void saturate_sv( IplImage* img ) {
  26. for( int y=0; y<img->height; y++ ) {
  27. uchar* ptr = (uchar*) (
  28. img->imageData + y * img->widthStep
  29. );
  30. for( int x=0; x<img->width; x++ ) {
  31. ptr[3*x+1] = 255;
  32. ptr[3*x+2] = 255;
  33. }
  34. }
  35. }
  36. int main( int argc, char** argv )
  37. {
  38. IplImage* img = cvLoadImage( argv[1] );
  39. cvNamedWindow("Example1", CV_WINDOW_AUTOSIZE );
  40. saturate_sv(img);
  41. cvShowImage("Example1", img );
  42. cvWaitKey(0);
  43. cvReleaseImage( &img );
  44. cvDestroyWindow("Example1");
  45. }