最近仔细看了一下API,随便写了一个salt&pepper函数,速度还行。
void saltAndPeper(Mat image,int phi = 64)
{
int hight = image.rows;
int width = image.cols;
srand((unsigned)time((0)));
for (int i = 0; i < phi; i++)
{
int x = rand() % hight;
int y = rand() % width;
image.at<cv::Vec3b>(x, y)[0]