Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Mat LinearFunction(Mat Grey, int threshold, int threshold2)
- {
- Mat LinearImage = Mat::zeros(Grey.size(), CV_8UC1);
- for (int i = 0; i < Grey.rows; i++)
- {
- for (int j = 0; j < Grey.cols; j++)
- {
- if ((Grey.at<uchar>(i, j) < threshold))
- {
- LinearImage.at<uchar>(i, j) = Grey.at<uchar>(i, j);
- }
- else if ((Grey.at<uchar>(i, j) >= threshold) && (Grey.at<uchar>(i, j) <= threshold2))
- {
- LinearImage.at<uchar>(i, j) = threshold;
- }
- //Can ignore the else because of Mat::zeros(Grey.size(), CV_8UC1);
- else
- {
- LinearImage.at<uchar>(i, j) = 0;
- }
- }
- }
- return LinearImage;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement