opencv实现图像像素点反转
最近在学习opencv图像处理,自学到将一副原图像上的像素点像素值反转,再输出新的图像
创新互联建站基于成都重庆香港及美国等地区分布式IDC机房数据中心构建的电信大带宽,联通大带宽,移动大带宽,多线BGP大带宽租用,是为众多客户提供专业服务器托管报价,主机托管价格性价比高,为金融证券行业资阳主机托管,ai人工智能服务器托管提供bgp线路100M独享,G口带宽及机柜租用的专业成都idc公司。
,代码如下:
#include
#include
#include
using namespace cv;
using namespace std;
int main(int argc, char **argv)
{
Mat gray_image;
Mat src = imread("C:/Users/Administrator/Desktop/1.jpg");
if (!src.data)
{
cout << "could not load image..." << endl;
return -1;
}
cvNamedWindow("原图",WINDOW_AUTOSIZE);
imshow("原图", src);
cvtColor(src, gray_image, CV_BGR2GRAY);
//namedWindow("output", CV_WINDOW_AUTOSIZE);
//imshow("output", gray_image);
//int height = gray_image.rows;
//int width = gray_image.cols;
Mat dst;
dst.create(src.size(), src.type());
int height = src.rows;
int width = src.cols;
int nc = src.channels();
for (int row = 0; row < height; row++) {
for (int col = 0; col < width; col++) {
//单通道
if (nc == 1) {
int gray = gray_image.at
gray_image.at
}
//三通道
else if (nc == 3) {
int b = src.at
int g = src.at
int r = src.at
dst.at
dst.at
dst.at
gray_image.at
}
}
}
imshow("output", gray_image);
//bitwise_not(src, dst);
imshow("gray invert", dst);
waitKey(0);
return 0;
}
分享标题:opencv实现图像像素点反转
网站链接:http://pwwzsj.com/article/jegcpp.html