![](https://img-blog.csdnimg.cn/20201014180756930.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
opencv
ming.zhang
爱科技,爱生活
展开
-
学习c++版opencv3.4之3
提高图像对比度1.矩阵的掩膜操作filter2D():获取图像像素指针,掩膜操作。2.staturate_cast<uchar>() #使像素值在0-255之间。2.统计时间,getTickCount()#include <opencv2/opencv.hpp>#include <iostream>#include <math.h...原创 2018-09-23 10:16:02 · 588 阅读 · 0 评论 -
学习c++版opencv3.4之24-直方图均衡化
直方图均衡化equalizeHist。可以用来提高图像对比度equalizeHist:#include <opencv2/opencv.hpp>#include <iostream>#include <math.h>using namespace std;using namespace cv;Mat src, dst, src_g...原创 2018-10-06 08:14:58 · 2303 阅读 · 0 评论 -
学习c++版opencv3.4之1
首先下载对应操作系统opencv源码,编译等操作。通过下面的一个示例,说明opencv安装成功。#include <opencv2/opencv.hpp>#include <iostream>using namespace std;using namespace cv;// a demo for opencvint main(){ Mat src...原创 2018-09-23 09:54:43 · 539 阅读 · 0 评论 -
学习c++版opencv3.4之2
加载imread,修改cvtColor,保存imwrite图像。#include <opencv2/opencv.hpp>#include <iostream>using namespace std;using namespace cv;int main(){ Mat src, dst; src = imread("/Users/ming/...原创 2018-09-23 10:07:03 · 368 阅读 · 0 评论 -
学习c++版opencv3.4之16-自定义线性滤波
自定义线性滤波。Robert算子:#include <opencv2/opencv.hpp>#include <iostream>#include <math.h>using namespace std;using namespace cv;int threshold_value = 100, threshold_max = 255;i...原创 2018-09-28 23:37:21 · 350 阅读 · 0 评论 -
学习c++版opencv3.4之25-直方图计算
直方图计算。#include <opencv2/opencv.hpp>#include <iostream>#include <math.h>using namespace std;using namespace cv;Mat src, dst, src_gray;int main(){ src = imread("/Users...原创 2018-10-06 10:37:46 · 672 阅读 · 1 评论 -
学习c++版opencv3.4之17-边缘处理
边缘处理。原创 2018-09-28 23:39:25 · 362 阅读 · 0 评论 -
学习c++版opencv3.4之18-sobel算子
sobel算子得到的是图像在x方向和y方向的梯度图像。拉普拉斯算子得到二阶梯度。#include <opencv2/opencv.hpp>#include <iostream>#include <math.h>using namespace std;using namespace cv;int threshold_value = ...原创 2018-09-28 23:53:46 · 1045 阅读 · 0 评论 -
学习c++版opencv3.4之19-Laplance算子
Laplance算子:求图像二阶导数图像。#include <opencv2/opencv.hpp>#include <iostream>#include <math.h>using namespace std;using namespace cv;int threshold_value = 100, threshold_max = 25...原创 2018-09-29 23:23:19 · 245 阅读 · 0 评论 -
学习c++版opencv3.4之20-canny边缘检测
Canny边缘检测。#include <opencv2/opencv.hpp>#include <iostream>#include <math.h>using namespace std;using namespace cv;int threshold_value = 100, threshold_max = 255;int thre...原创 2018-09-30 21:42:19 · 1010 阅读 · 0 评论 -
python/cv2对长方形图像进行等比例缩放及对周围常数值(0)填充zero padding
#coding:utf-8import osimport cv2import globimport numpy as npdef mkdir(path): if not os.path.exists(path): os.mkdir(path)def process_image(img): size = img.shape h, w = si...原创 2018-12-08 00:28:45 · 10241 阅读 · 7 评论 -
学习c++版opencv3.4之15-基本阈值操作
图像阈值,阈值类型。阈值二值化。#include <opencv2/opencv.hpp>#include <iostream>#include <math.h>using namespace std;using namespace cv;int threshold_value = 100;int threshold_max = 255...原创 2018-09-28 00:01:56 · 538 阅读 · 0 评论 -
学习c++版opencv3.4之14-图像金字塔
图像金字塔,上采样与将采样。上采样与下采样过程中图像的尺寸会发生变化,与图像普通的resize改变尺寸不同的是,上采样下采样这种变化保留了不同尺度下图像的特征。一个图像金字塔由一系列不同尺寸图像组成,最低下的尺寸最大,最上方的尺寸最小,从空间上由上向下看就像一个金字塔。图像金字塔包括两种:高斯金字塔,主要进行降采样;拉普拉斯金字塔,根据它的上层降采样的图像进行重建一张图像(上采样)。高...原创 2018-09-26 22:51:09 · 1126 阅读 · 0 评论 -
学习c++版opencv3.4之23-像素重映射
像素重映射。 #include <opencv2/opencv.hpp>#include <iostream>#include <math.h>using namespace std;using namespace cv;Mat src, dst, map_x, map_y;int index_num = 3;void my_map(...原创 2018-10-05 19:42:05 · 146 阅读 · 0 评论 -
学习c++版opencv3.4之4
1.新建空图2.完全复制图像clone和copyTo3.获取图像像素值#include <opencv2/opencv.hpp>#include <iostream>using namespace std;using namespace cv;int main(){ Mat src; src = imread("/Users/min...原创 2018-09-23 16:22:55 · 1698 阅读 · 0 评论 -
学习c++版opencv3.4之5
对图像操作:1.读写图像,imread,imwrite2.获取像素,单通道:img.at<uchar>(i, j),获取3通道的一个通道值:img.at<Vec3b>(i, j)[0]3.修改像素,对img.at<uchar>(i, j)直接赋值即可。#include <opencv2/opencv.hpp>#include &l...原创 2018-09-23 19:01:35 · 576 阅读 · 0 评论 -
学习c++版opencv3.4之6
线性混合操作:addWeighted(src_linux, alpha, src_win7, 1-alpha, gamma, dst) //alpha可以调节对比度;gamma可以调节亮度#include <opencv2/opencv.hpp>#include <iostream>using namespace std;using namespace c...原创 2018-09-23 21:39:35 · 525 阅读 · 0 评论 -
学习c++版opencv3.4之7
调整图像亮度与对比度。点操作是针对某个像素,如修改某个位置点像素值;邻域操作如卷积变换,是基于区域的操作。Mat img = Mat::zeros(src.size(), src.type()); /定义空图像saturate_cast<uchar>(value); //使value的值在0-255,value为一个像素值img.at<Vec3b>(i,...原创 2018-09-23 22:30:23 · 522 阅读 · 0 评论 -
学习c++版opencv3.4之8
在图像上绘制线段,矩形,圆,椭圆,文字。#include <opencv2/opencv.hpp>#include <iostream>#include <math.h>using namespace std;using namespace cv;Mat src; //全局变量string drawdemo = "draw line to i...原创 2018-09-24 11:00:52 · 387 阅读 · 0 评论 -
学习c++版opencv3.4之9,10-模糊图像
图像模糊:为了降低图像噪声。常见的为Smooth, blur,它们利用卷积计算实现,这些卷积算子都是线性操作,所以又称为线性滤波。均值滤波核的权重都为1,最终像素取个结果和的均值,最终导致图像各个区域的像素值比较均匀,无法克服边缘像素信息丢失。高斯滤波核的权重是一个高斯分布的值,滤波后较大的像素值仍然较大,因此图像会保留原有的特点,但只是部分地克服了边缘信息的丢失,无法完全避免,因...原创 2018-09-24 16:16:07 · 616 阅读 · 0 评论 -
学习c++版opencv3.4之11-膨胀腐蚀
形态学操作。膨胀:结构B在图像A上面移动,B的中心定义为锚点,计算B覆盖下A的最大像素值来替换锚点的像素,B的形状可以是任意的。膨胀类似于中值滤波时取最大值而不是中间值,且滤波时核的形状比较单一,但是膨胀中B的形状可以为矩形,圆形等。Mat structure_element = getStructuringElement(MORPH_RECT, Size(3,3)); //定义B的形状及...原创 2018-09-24 18:56:55 · 3139 阅读 · 0 评论 -
学习c++版opencv3.4之12-形态学操作
形态学操作常常用在二值化的图像,和灰度图像中,直接用在三通道的彩色图像中效果不明显,因此可将其二值化。开操作open:先腐蚀后膨胀。假设背景为黑色,可以把前景离散的小对象去掉。闭操作close:先膨胀后腐蚀。假设背景为黑色,可以填充前景里的小洞。Mat kernel = getStructuringElement(MORPH_RECT, Size(7,7)); //设置核morph...原创 2018-09-24 20:07:25 · 839 阅读 · 0 评论 -
学习c++版opencv3.4之13-形态学操作的应用
使用形态学操作提取水平与垂直线。#include <opencv2/opencv.hpp>#include <iostream>#include <math.h>using namespace std;using namespace cv;Mat src ,gray_src, dst;int main(){ src = imrea...原创 2018-09-25 23:53:06 · 225 阅读 · 0 评论 -
学习c++版opencv3.4之21-霍夫直线检测
霍夫变换用来直线,圆等检测,使用的前提条件是边缘检测(如canny,sobel等)已经完成。#include <opencv2/opencv.hpp>#include <iostream>#include <math.h>using namespace std;using namespace cv;Mat src, dst;int ...原创 2018-09-30 22:41:25 · 3072 阅读 · 0 评论 -
学习c++版opencv3.4之22-霍夫圆检测
霍夫圆检测。从直角坐标系转为极坐标系后圆心比较亮。#include <opencv2/opencv.hpp>#include <iostream>#include <math.h>using namespace std;using namespace cv;Mat src, dst;Mat gray_img;int main(...原创 2018-10-01 14:54:04 · 1338 阅读 · 0 评论 -
ubuntu16.04 安装opencv过程
ubuntu16.04 安装opencv过程:从这下载源码 https://opencv.org/releases.html或者链接: https://pan.baidu.com/s/1qwj0cBKNvSVisl8JkuKMZw 提取码: pmeu,这里使用的opencv是3.4.5unzip opencv-3.4.5.zipsudo apt-get ins...原创 2019-04-21 21:05:25 · 981 阅读 · 0 评论