Advertisement
Guest User

Untitled

a guest
Dec 11th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. Mat LinearFunction(Mat Grey, int threshold, int threshold2)
  2. {
  3. Mat LinearImage = Mat::zeros(Grey.size(), CV_8UC1);
  4.  
  5. for (int i = 0; i < Grey.rows; i++)
  6. {
  7. for (int j = 0; j < Grey.cols; j++)
  8. {
  9. if ((Grey.at<uchar>(i, j) < threshold))
  10. {
  11. LinearImage.at<uchar>(i, j) = Grey.at<uchar>(i, j);
  12. }
  13. else if ((Grey.at<uchar>(i, j) >= threshold) && (Grey.at<uchar>(i, j) <= threshold2))
  14. {
  15. LinearImage.at<uchar>(i, j) = threshold;
  16. }
  17. //Can ignore the else because of Mat::zeros(Grey.size(), CV_8UC1);
  18. else
  19. {
  20. LinearImage.at<uchar>(i, j) = 0;
  21.  
  22. }
  23. }
  24.  
  25. }
  26.  
  27. return LinearImage;
  28.  
  29.  
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement