noise injection (Gaussian noise and salt-and-pepper noise)
发布时间
阅读量:
阅读量
椒盐噪声的生成过程:
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
void salt(cv::Mat &image, int n) {
int i, j;
for (int k = 0; k<n; k++) {
// rand() is the MFC random number generator
i = rand() % image.cols;
j = rand() % image.rows;
if (image.channels() == 1) { // gray-level image
image.at<uchar>(j, i) = 255;
}
else if (image.channels() == 3) { // color image
image.at<cv::Vec3b>(j, i)[0] = 255;
image.at<cv:
全部评论 (0)
还没有任何评论哟~
