//掩模,图像增强的两种方法
cols = src.cols * src.channels();
rows = src.rows;
int offset = src.channels();
Mat dst1 = Mat::zeros(src.size(), src.type());
/*for (int row = 1; row < rows; row++)
{
const uchar* current = src.ptr<uchar>(row);
const uchar* previous = src.ptr<uchar>(row - 1);
const uchar* next = src.ptr<uchar>(row + 1);
uchar* output = img.ptr<uchar>(row);
for (int col = offset; col < cols; col++)
output[col] = saturate_cast<uchar>(5 * current[col] - (current[col - offset] + current[col + offset] + previous[col] + next[col]));
}*/
Mat kernel = (Mat_<char>(3, 3) << 0, -1, 0, -1, 5, -1, 0, -1, 0);
filter2D(src, dst1, src.depth(),kernel);
opencv图像增强
最新推荐文章于 2024-09-20 21:28:38 发布