// remove-color.cpp
// @mango
#include<iostream>#include<cmath>#include<opencv2/opencv.hpp>intmain(){cv::Matimg=cv::imread("fruit.jpg");if(img.empty()){std::cout<<"Failed to read the image!"<<std::endl;return-1;}for(size_ti=0;i<img.rows;i++){for(size_tj=0;j<img.cols;j++){intmax=std::max(std::max(img.at<cv::Vec3b>(i,j)[0],img.at<cv::Vec3b>(i,j)[1]),img.at<cv::Vec3b>(i,j)[2]);intmin=std::min(std::min(img.at<cv::Vec3b>(i,j)[0],img.at<cv::Vec3b>(i,j)[1]),img.at<cv::Vec3b>(i,j)[2]);for(size_tk=0;k<3;k++){img.at<cv::Vec3b>(i,j)[k]=(max+min)/2;}}}cv::imshow("去色滤镜",img);cv::waitKey(0);return0;}