Advertisement
Guest User

Untitled

a guest
Mar 25th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. #include "PDIUtils.h"
  2. #include <algorithm>
  3. #include <cmath>
  4.  
  5. cv::Mat PDIUtils::escalaCinza(cv::Mat imagemColorida) {
  6. cv::Mat aux = imagemColorida.clone();
  7.  
  8. cv::cvtColor(imagemColorida, aux, cv::COLOR_BGR2GRAY);
  9.  
  10. return aux;
  11. }
  12.  
  13. cv::Mat PDIUtils::negativo(cv::Mat imagemBase) {
  14. cv::Mat aux = imagemBase.clone();
  15.  
  16. for (int x = 0; x < aux.rows; x++) {
  17. for (int y = 0; y < aux.cols; y++) {
  18. PixelEC pixel = imagemBase.at<PixelEC>(x, y);
  19. PixelEC negativo = 255 - pixel;
  20. aux.at<PixelEC>(x, y) = negativo;
  21. }
  22. }
  23.  
  24. return aux;
  25. }
  26.  
  27. cv::Mat PDIUtils::canal(cv::Mat imagemColorida, int canal) {
  28. cv::Mat aux = escalaCinza(imagemColorida);
  29.  
  30. for (int x = 0; x < aux.rows; x++) {
  31. for (int y = 0; y < aux.cols; y++) {
  32.  
  33. Pixel pixel = imagemColorida.at<Pixel>(x, y);
  34. PixelEC pCanal = pixel[canal];
  35.  
  36.  
  37. aux.at<PixelEC>(x, y) = pCanal;
  38. }
  39. }
  40.  
  41. return aux;
  42. }
  43.  
  44.  
  45. std::vector<float> PDIUtils::histograma(cv::Mat imagem) {
  46. std::vector<float> hist = std::vector<float>(256);
  47.  
  48. for (int i = 0; i < imagem.rows; i++) {
  49. for (int j = 0; j < imagem.cols; j++) {
  50. PixelEC pixel = imagem.at<PixelEC>(i, j);
  51. hist[pixel]++;
  52. }
  53.  
  54. }
  55. //faz o histograma
  56.  
  57. return hist;
  58. }
  59.  
  60.  
  61. cv::Mat PDIUtils::limiarizacao(cv::Mat imagemBase, int limiar) {
  62. cv::Mat aux = imagemBase.clone();
  63.  
  64. //limiariza a imagem
  65.  
  66. return aux;
  67. }
  68.  
  69. cv::Mat PDIUtils::janelamento(cv::Mat imagemBase, int li, int ls) {
  70. cv::Mat aux = imagemBase.clone();
  71.  
  72. //faz o janelamento da imagem
  73.  
  74. return aux;
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement