in main.cpp:
case bba::ACTION_FILTER_IDENTITY:
{
cv::Mat img = stack.top();
stack.pop();
bba::identity(img);
img = bba::identity(img); // alternative Form
stack.push(img);
}
break;
aufg0.hpp:
#pragma once
#include <opencv2/opencv.hpp>
namespace bba {
void identity(cv::Mat & img);
}
aufg0.cpp:
#include "aufg0.hpp"
bba::identity(cv::Mat & img) {
for (int y = 0; y < img.rows; y++) {
for (int x = 0; x < img.cols; x++) {
// TODO
}
}
}
in aufg0.cpp:
img.at<unsigned char>(y,x)
Dokumentation cv::Mat::at<T>(y,x)
→ cv::Mat::at<T>(i)
in aufg0.cpp:
std::cerr << int(img.at<unsigned char>(y,x)) << " ";
…
std::cerr << std::endl;
in aufg0.cpp:
img.at<unsigned char>(y,x) = img.at<unsigned char>(y,x);
aufg0.cpp:
for (int y = 0; y < img.rows; y++) {
for (int x = 0; x < img.cols; x++) {
img.at<unsigned char>(y,x) = img.at<unsigned char>(y,x);
}
}
umformulieren zu
bba::for_each_pixel(img, [](cv::Mat & m, int y, int x) {
m.at<unsigned char>(y,x) = m.at<unsigned char>(y,x);
});