以下使用 img * 5; 将每一个像素的RGB值都乘以5.
最后打印来验证结果。
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <linux/videodev2.h>
#include <string.h>
#include <sys/mman.h>
#include <assert.h>
#include <opencv2/opencv.hpp>
#include <opencv2/core.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/highgui.hpp>
using namespace std;
using namespace cv;
typedef cv::Point3_<uint8_t> Pixel;
int main() {
Mat img(20, 20, CV_8UC3, Scalar(1, 1, 50));
Mat tmp2 = img * 5;
for (Pixel p : cv::Mat_<Pixel>(tmp2)) {
printf("%d,%d,%d\n",p.x,p.y,p.z);
}
imwrite("out.jpg", tmp2);
return 0;
}
本文介绍了一个简单的图像处理程序,该程序使用OpenCV库读取一个20x20像素的图像,并将每个像素的RGB值乘以5进行颜色增强。通过遍历图像中的每个像素并打印其新的RGB值来验证操作的有效性。
897

被折叠的 条评论
为什么被折叠?



