Advertisement
Guest User

Untitled

a guest
Oct 18th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. #include <QCoreApplication>
  2. #include "opencv2/core/core.hpp"
  3. #include "opencv2/highgui/highgui.hpp"
  4. #include "opencv2/imgproc/imgproc.hpp"
  5.  
  6. using namespace cv;
  7. using namespace std;
  8.  
  9. int main(int argc, char *argv[])
  10. {
  11. QCoreApplication a(argc, argv);
  12.  
  13. auto image = imread("/home/skirtek/Pulpit/photo.jpeg");
  14. vector<Mat> splitted;
  15. Mat hsv;
  16. Mat emptyImage = Mat::zeros(Size(image.cols, image.rows), CV_8UC1);
  17. cvtColor(image, hsv, CV_RGB2HSV);
  18. split(hsv, splitted);
  19. imshow("HSV FULL", hsv);
  20.  
  21. vector<Mat> channels;
  22. channels = {splitted[0],emptyImage,emptyImage};
  23.  
  24. Mat hue;
  25. merge(channels, hue);
  26. imshow("Hue", hue);
  27.  
  28. channels.clear();
  29. channels = {emptyImage,splitted[1],emptyImage};
  30.  
  31. Mat saturation;
  32. merge(channels, saturation);
  33. imshow("Saturation", saturation);
  34.  
  35. channels.clear();
  36. channels = {emptyImage,emptyImage,splitted[2]};
  37.  
  38. Mat value;
  39. merge(channels, value);
  40. imshow("Value", value);
  41.  
  42. channels.clear();
  43. channels = {splitted[0],splitted[1],splitted[2]};
  44.  
  45. Mat originalImage;
  46. merge(channels, originalImage);
  47. imshow("OriginaIlmage",originalImage);
  48.  
  49. waitKey(0);
  50. destroyAllWindows();
  51. return a.exec();
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement