目录
note
code
test
note
图像点运算之灰度变换之非线性变换
例如:y = 10 * x ^ 0.5
code
void noline_convert_fun(uchar& in, uchar& out) {
out = 10 * (uchar)pow((float)in, 0.5);
}
void img_nonline_convert(Mat& src, Mat& res) {
if (src.empty()) {
printf("src empty\n");
return;
}
int src_rows = src.rows;
int src_cols = src.cols;
res = Mat(src_rows, src_cols, CV_8UC1);
for (int i = 0; i < src_rows; ++i) {
for (int j = 0; j < src_cols; ++j) {
noline_convert_fun(src.at<uchar>(i,j), res.at<uchar>(i,j));
}
}
}
test