Advertisement
Guest User

Untitled

a guest
Jan 25th, 2013
286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. #include <iostream>
  2. #include "opencv2/highgui/highgui.hpp"
  3. #include "opencv2/imgproc/imgproc_c.h"
  4. #include "opencv2/imgproc/imgproc.hpp"
  5. #include <stdio.h>
  6. using namespace std;
  7. using namespace cv;
  8.  
  9. int main()
  10. {
  11.  
  12. Mat newImg,img;
  13. img=imread("img.jpeg");
  14. cvtColor(img, newImg, CV_BGR2HSV);
  15.  
  16. imwrite("test.jpg", newImg);
  17.  
  18. vector<Mat> hsv_planes;
  19. split(newImg, hsv_planes); //geting the color plans of image
  20. int param = -70; // the value that I'm seting for V
  21. for (int y = 0; y < newImg.rows; y++) {
  22. for (int x = 0; x < newImg.cols; x++) {
  23.  
  24. Vec3b pixel = hsv_planes[2].at<Vec3b>(y, x);
  25. pixel[0] = 0;
  26. pixel[1] = 0;
  27. pixel[2] = param;
  28.  
  29. hsv_planes[2].at<Vec3b>(y, x) = pixel;
  30.  
  31. }
  32. }
  33.  
  34. merge(hsv_planes, newImg);
  35. Mat imagem;
  36. cvtColor(newImg, imagem, CV_HSV2BGR);
  37.  
  38. imwrite("final.jpg", imagem);
  39.  
  40. return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement