当前位置:网站首页>Opencv code
Opencv code
2022-04-22 06:10:00 【From deliberate to habit】
#include<opencv2/opencv.hpp>
#include
using namespace std;
using namespace cv;
int main()
{
// Display images
Mat src;
src = imread(“C:\Users\siasun\Desktop\10.jpg”);
if (src.empty())
{
cout << “counld not load image…” << endl;
return -1;
}
namedWindow(“image”, CV_WINDOW_AUTOSIZE);
imshow(“image”, src);
// Displays a grayscale image
Mat dst;
cvtColor(src, dst, CV_BGR2GRAY);
namedWindow("image", CV_WINDOW_AUTOSIZE);
imshow("image", dst);
printf("input image channels:%d\n", dst.channels());
// Display image rows and columns
int cols = dst.cols;
int rows = dst.rows;
printf("rows:%d cols:%d\n", rows,cols);
const uchar*firstRow = dst.ptr<uchar>(0);
printf("input image channels:%d\n", *firstRow);
// Create a mat Images
Mat M(3, 3, CV_8UC3, Scalar(0, 0, 255));
imshow("image", M);
// Create a blank image consistent with a graph size type
Mat m2 = Mat::zeros(dst.size(), dst.type());
imshow("image", m2);
// Mask , Two methods of image enhancement
cols = src.cols * src.channels();
rows = src.rows;
int offset = src.channels();
Mat dst1 = Mat::zeros(src.size(), src.type());
/*for (int row = 1; row < rows; row++)
{
const uchar* current = src.ptr<uchar>(row);
const uchar* previous = src.ptr<uchar>(row - 1);
const uchar* next = src.ptr<uchar>(row + 1);
uchar* output = img.ptr<uchar>(row);
for (int col = offset; col < cols; col++)
output[col] = saturate_cast<uchar>(5 * current[col] - (current[col - offset] + current[col + offset] + previous[col] + next[col]));
}*/
Mat kernel = (Mat_<char>(3, 3) << 0, -1, 0, -1, 5, -1, 0, -1, 0);
filter2D(src, dst1, src.depth(),kernel);
imshow("image", dst1);
imshow("image1", src);
waitKey(0);
return 0;
}
版权声明
本文为[From deliberate to habit]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220542470841.html
边栏推荐
- stm32单片机与LD3320语音模块交互法二
- js等待异步执行完成后在执行
- Code color difference of QT learning
- Invalid transform origin base point setting
- 常见面试题 - 4(MySQL)
- Analysis of Modbus Protocol in TCP communication
- STM32 printf redirection virtual oscilloscope
- On the relationship between the Euler angle of RT matrix and the type of pose in Halcon in hand eye calibration
- IWDG
- Chapter 87 leetcode sword refers to offer dynamic programming (IV) maximum sum of continuous subarrays
猜你喜欢

CAN 数据帧,远程帧,错误帧,以及出错重连

Access problems after setting up the local server

关于手眼标定中RT矩阵的欧拉角和Halcon中pose的类型之间的关系

Part 73 leetcode exercise (6) 6 Zigzag transformation

Part 74 leetcode exercise (VII) 7 Integer inversion

Photoresist for learning of Blue Bridge Cup embedded expansion board

WGS84 coordinate conversion, map picking, WGS84 coordinate tool recommended

Part 75 leetcode exercise (8) 8 String to integer

Part 72 leetcode exercise (V) 5 Longest Palindromic Substring

Calibration principle of robot tool coordinate system
随机推荐
机器人抓取物体原理初步
The 7th Blue Bridge Cup embedded provincial competition: analog liquid level detection and alarm system "
QQueue使用介绍
蓝桥杯嵌入式学习之双路AD采集
Binary search and its classical applications (left boundary, right boundary, etc.)
Part 84 leetcode sword refers to offer dynamic programming (I) Fibonacci sequence
Chapter 86 leetcode refers to offer dynamic programming (III) maximum profit of stock
Clock
IWDG
Blue Bridge Cup embedded expansion board learning nixie tube
DS18B20 of Blue Bridge Cup embedded expansion board learning
stm32单片机与LD3320语音模块交互法二
STM32 learning note 2 - set GPIO register to realize running water lamp
蓝桥杯嵌入式扩展板学习之LIS302DL
Assemble makefile
CMake及交叉工具编译链的安装使用
TCP通讯MODBUS协议解析
Can data frame, remote frame, error frame, and error reconnection
Analysis of Modbus Protocol in TCP communication
QWebsocket通信