opencv入门三函数说明
2018-01-07 21:49
976 查看
函数说明
medianBlur bilateralFilter createTrackbarmedianBlur
官方说明:通过周围数据中值来进行平滑,优点效果好,就是慢就是慢The function smoothes an image using the median filter with the
参数说明
@param src input 1-, 3-, or 4-channel image; when ksize is 3 or 5, the image depth should be
CV_8U, CV_16U, or CV_32F, for larger aperture sizes, it can only be CV_8U.
@param dst destination array of the same size and type as src.
//内核大小只要奇数大于1
@param ksize aperture linear size; it must be odd and greater than 1, for example: 3, 5, 7 …
@sa bilateralFilter, blur, boxFilter, GaussianBlur
示例
//中值滤波 int medianBlurimg(const string & filename) { Mat srcimg = imread(filename); Mat dst; medianBlur(srcimg, dst, 10 * 2 + 1); imshow("medianBlurimg", dst); //waitKey(0); return 0; }
bilateralFilter
官方说明:去燥并保证边缘完整The function applies bilateral filtering to the input image, as described in
http://www.dai.ed.ac.uk/CVonline/LOCAL_COPIES/MANDUCHI1/Bilateral_Filtering.html
bilateralFilter can reduce unwanted noise very well while keeping edges fairly sharp. However, it is
very slow compared to most filters.
参数说明
@param src Source 8-bit or floating-point, 1-channel or 3-channel image.
@param dst Destination image of the same size and type as src .
//象素直径如果不是正数它会从sigmaspace算出来
@param d Diameter of each pixel neighborhood that is used during filtering. If it is non-positive,
it is computed from sigmaSpace.
//颜色滤波数越大表示边缘越多的颜色 被混合到一起
@param sigmaColor Filter sigma in the color space. A larger value of the parameter means that
farther colors within the pixel neighborhood (see sigmaSpace) will be mixed together, resulting
in larger areas of semi-equal color.
//空间参数,数越大越大的区域颜色相同第三个参数大于0邻域大小与此参数无关,否则正此参数成正比正相关
@param sigmaSpace Filter sigma in the coordinate space. A larger value of the parameter means that
farther pixels will influence each other as long as their colors are close enough (see sigmaColor
). When d>0, it specifies the neighborhood size regardless of sigmaSpace. Otherwise, d is
proportional to sigmaSpace.
@param borderType border mode used to extrapolate pixels outside of the image, see cv::BorderTypes
示例代码
Mat srcimg = imread(filename); // Mat dst; g_srcImage = srcimg.clone(); // bilateralFilter(srcimg, dst, 25,25*2,25/2); // imshow("bilateralFilterimg",dst); namedWindow("bilateralFilterimg", 1);
createTrackbar
官方说明:就是一个slider来改变相关数值大小The function createTrackbar creates a trackbar (a slider or range control) with the specified name
and range, assigns a variable value to be a position synchronized with the trackbar and specifies
the callback function onChange to be called on the trackbar position change. The created trackbar is
displayed in the specified window winname.
参数说明
//轨迹名
@param trackbarname Name of the created trackbar.
//窗口名
@param winname Name of the window that will be used as a parent of the created trackbar.
//滑块初始位置指针类型
@param value Optional pointer to an integer variable whose value reflects the position of the
slider. Upon creation, the slider position is defined by this variable.
//滑块最大值 ,最小值始终为0
@param count Maximal position of the slider. The minimal position is always 0.
//更改回调函数
@param onChange Pointer to the function to be called every time the slider changes position. This
function should be prototyped as void Foo(int,void*); , where the first parameter is the trackbar
position and the second parameter is the user data (see the next parameter). If the callback is
the NULL pointer, no callbacks are called, but only value is updated.
//传给用户数据 全局变量可以不用考虑
@param userdata User data that is passed as is to the callback. It can be used to handle trackbar
events without using global variables.
示例代码
//双边滤波 int bilateralFilterimg(const string & filename) { Mat srcimg = imread(filename); // Mat dst; g_srcImage = srcimg.clone(); // bilateralFilter(srcimg, dst, 25,25*2,25/2); // imshow("bilateralFilterimg",dst); namedWindow("bilateralFilterimg", 1); //创建轨迹条 createTrackbar("参数值:", "bilateralFilterimg", &g_nMedianBlurValue, 50, on_MedianBlur); on_MedianBlur(g_nMedianBlurValue, 0); /* Mat image1(srcimg.rows, srcimg.cols, srcimg.type(), Scalar(180, 120, 50)); for (int x = 0; x < srcimg.cols; x++) { for (int y = 0; y < srcimg.rows; y++) { image1.at<Vec3b>(Point(x, y))[0] = 0;// srcimg.at<Vec3b>(Point(x, y))[0]; image1.at<Vec3b>(Point(x, y))[1] = srcimg.at<Vec3b>(Point(x, y))[1]; image1.at<Vec3b>(Point(x, y))[2] = 0;// srcimg.at<Vec3b>(Point(x, y))[2]; } } imshow("image1", image1);*/ waitKey(0); return 0; } void on_MedianBlur(int, void *) { Mat g_dstImage4= g_srcImage.clone();//一次就好 // medianBl 4000 ur(g_srcImage, g_dstImage4, g_nMedianBlurValue * 2 + 1); bilateralFilter(g_srcImage, g_dstImage4, g_nMedianBlurValue, g_nMedianBlurValue *2, g_nMedianBlurValue /2); imshow("bilateralFilterimg", g_dstImage4); }
相关文章推荐
- opencv入门-函数说明
- opencv入门二函数说明
- OpenCV中寻找轮廓函数cvFindContours的使用说明以及序列cvSeq的用法说明
- OpenCV入门:(六:基础画图函数)
- OpenCV中寻找轮廓函数cvFindContours的使用说明以及序列cvSeq的用法说明
- python opencv入门 更多关于轮廓的函数(20)
- OpenCV中寻找轮廓函数cvFindContours的使用说明以及序列cvSeq的用法说明
- OpenCV中用于图片显示的函数参数说明
- opencv:cvCreateImage函数说明
- 【技术】OpenCV入门:3.1.0版本中的imread()函数flag参数
- OpenCV之mixChannels()函数使用说明
- opencv日常学习之approxPolyDP函数和boundingRect函数说明
- OpenCV之mixChannels()函数使用说明
- 【openCV入门之三】数据结构和绘图函数
- 封装opencvdll 的函数说明
- CvCreateImage函数说明以及一些OpenCv中函数的相关说明
- 【OpenCV学习笔记】【函数学习】十四(cvSeq的用法说明(功能很多,按照需求使用))
- Opencv::findContours函数参数说明及相关函数
- opencv 中函数的一相关说明,如:cvtColor和cvCvtColor区别
- OpenCV混合高斯模型函数注释说明