#include <opencv2/core/core.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/opencv.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main(int argc, char** args) {
Mat image = imread("E:/15.JPG", IMREAD_COLOR);
if (image.empty()) {
cout << "could not find the image resource..." << std::endl;
return -1;
}
namedWindow("input", CV_WINDOW_AUTOSIZE);
imshow("input", image);
Mat grayImg;
cvtColor(image, grayImg, COLOR_BGR2GRAY);
Mat sobelx;
Sobel(grayImg, sobelx, CV_32F, 1, 0);
double minVal, maxVal;
minMaxLoc(sobelx, &minVal, &maxVal); //find minimum and maximum intensities
Mat draw;
sobelx.convertTo(draw, CV_8U, 255.0 / (maxVal - minVal), -minVal * 255.0 / (maxVal - minVal));
imwrite("13.JPG",draw);
namedWindow("My Image", CV_WINDOW_AUTOSIZE);
imshow("My Image", draw);
waitKey
1.3opencv学习笔记图像颜色的反转
最新推荐文章于 2024-04-18 10:00:14 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)