一、遍历图像并对每个马赛克区域进行像素化处理
for (int y = 0; y < image.rows; y += blockSize) {for (int x = 0; x < image.cols; x += blockSize) {cv::Rect rect = cv::Rect(x, y, std::min(blockSize, image.cols - x), std::min(blockSize, image.rows - y));cv::Scalar mean = cv::mean(image(rect));cv::Mat roi = temp(rect);roi.setTo(mean);}}
二、直接使用resize,先缩小、后放大,以此产生马赛克效果