Opencv Tutorials學習筆記( 4.1.1版本)

以前對Opencv的掌握不太系統,最近工作不太忙,所以想系統的梳理下Opencv官方給出的學習例子,學習的目的主要是查漏補缺,在對圖像操作時,最優的方法是什麼,有比較重要的部分會做好筆記,便於將來直接進行查詢。

1、 Tutorials

1.1、 The Core Functionality (core module)

1.1.1Mat - The Basic Image Container

主要學習如何使用Mat和打印到控制檯

1.1.2How to scan images, lookup tables and time measurement with OpenCV

主要學習如何遍歷圖像,使用OpenCV衡量程序所使用的時間。

1.1.3 Mask operations on matrices

cv::filter2D 的使用方法

1.1.4 Operations with images

(1)將一個灰階圖像轉換爲黑色: img = Scalar(0);

(2)選擇一個感興趣區域:Rect r(10, 10, 100, 100); Mat smallImg = img(r);

(3)轉換圖像的數據類型: src.convertTo(dst, CV_32F);

(4)將32F數據類型的圖像轉換到8U

        Mat img = imread("image.jpg");
        Mat grey;
        cvtColor(img, grey, COLOR_BGR2GRAY);
        Mat sobelx;
        Sobel(grey, 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));
        namedWindow("image", WINDOW_AUTOSIZE);
        imshow("image", draw);
        waitKey();

1.1.5 Adding (blending) two images using OpenCV

主要是addWeighted的介紹

beta = ( 1.0 - alpha );

addWeighted( src1, alpha, src2, beta, 0.0, dst);

1.1.6 Changing the contrast and brightness of an image!

主要學習圖像的對比度和亮度調節

(1)在圖像的轉換過程中 cv::saturate_cast 的使用。

1.1.7Discrete Fourier Transform

離散傅里葉變換

1.1.8File Input and Output using XML and YAML files

使用cv::FileStorage 數據結構讀取和寫入XML和YAML文件

1.1.9How to use the OpenCV parallel_for_ to parallelize your code

使用opencv的parallel_for_framework框架進行並行加速

1.2、 Image Processing (imgproc module)

1.2.1Basic Drawing

(1)line()ellipse()rectangle()circle() fillPoly()

1.2.2Random generator and text with OpenCV

(隨機數生成器cv::RNG 和文字繪製cv::putText的使用方法

1.2.3Smoothing Images

blur()GaussianBlur()medianBlur()bilateralFilter()

1.2.4Eroding and Dilating

cv::erodecv::dilate

1.2.5More Morphology Transformations

Opening、Closing、Morphological Gradient、Top Hat、Black Hat。

1.2.6Hit-or-Miss

Hit-or-Miss 操作

1.2.7Extract horizontal and vertical lines by using morphological operations

使用形態學抽取出直線的的操作例子

1.2.8Image Pyramids

圖像金字塔使用pyrUp() 和pyrDown()實現上或者下采樣。

1.2.9Basic Thresholding Operations

cv::threshold的使用方法

1.2.10Thresholding Operations using inRange

inRange的使用方法,在HSV空間中根據顏色分割出一個物體。

1.2.11Making your own linear filters!

使用filter2D()創建自己的線性濾波器 

1.2.12Adding borders to your images

 使用copyMakeBorder()進行擴展邊界

1.2.13Sobel Derivatives

 Sobel()Scharr()算子的使用方法

1.2.14 Laplace Operator

拉普拉斯變換的操作,在變換結束之後需要使用

convertScaleAbs( dst, abs_dst );// converting back to CV_8U

1.2.15Canny Edge Detector

Canny 邊緣檢測的使用方法

1.2.16Hough Line Transform

霍夫直線檢測

1.2.17Hough Circle Transform

霍夫圓檢測

1.2.18Remapping

使用cv::remap實現圖像的簡單重映射,但是比較麻煩,如何映射需要自己指定。

1.2.19Affine Transformations

使用cv::warpAffine 和cv::getRotationMatrix2D 實現仿射變換

1.2.20Histogram Equalization

直方圖均衡化的使用方法

1.2.21Histogram Calculation

(1)split分割圖像

  vector<Mat> bgr_planes;
    split( src, bgr_planes );

(2)calcHist 計算直方圖

(3)normalize正則化圖像

1.2.22Histogram Comparison

使用cv::compareHist對比兩個直方圖之間的相似度,在對比之前要進行直方圖歸一化。

1.2.23Back Projection

學習使用直方圖在圖像中尋找相似物體,主要是cv::calcBackProject 的使用,適用於顏色分割的情況。

詳細解釋函數的意思:https://blog.csdn.net/keith_bb/article/details/70154219

cv::mixChannels,將部分通道複製到目標圖像的部分通道中。

1.2.24Template Matching

模板匹配方法 matchTemplate()

minMaxLoc() 尋找最大最小值

1.2.25Finding contours in your image

先濾波,後canny,最後findcoutors

1.2.26Convex Hull

使用cv::convexHull尋找凸包

1.2.27Creating Bounding boxes and circles for contours

使用cv::boundingRectcv::minEnclosingCircle獲取最小矩形和最小圓。

1.2.28Creating Bounding rotated boxes and ellipses for contours

 cv::minAreaRectcv::fitEllipse獲得最小包圍矩形和最小二乘法擬合的橢圓。

1.2.29Image Moments

(1)cv::moments求輪廓的矩//基於輪廓求得矩

(2) cv::contourArea和 cv::arcLength分別用來求封閉輪廓的面積和周長

1.2.30Point Polygon Test

cv::pointPolygonTest,判斷點是否在輪廓內部。

1.2.31Image Segmentation with Distance Transform and Watershed Algorithm

(1)學習的幾個函數: cv::filter2Dcv::distanceTransform 、cv::watershed

(2)分水嶺圖像風格的使用方法

①使用拉普拉斯算法對圖像進行銳化,使得邊緣更加清晰,有助於分水嶺算法的分割,得到imgResult

②使用distanceTransform函數得到分水嶺算法的種子點。

③使用cv::watershed進行分割,得到最終結果

1.2.32Out-of-focus Deblur Filter

如何修復失去焦點的圖像,通常是由於拍攝時候的抖動。

1.2.33Motion Deblur Filter

學習如何使用維也納濾波器修復運動模糊的圖片。

1.2.34Anisotropic image segmentation by a gradient structure tensor

將學習如何通過梯度結構張量分割具有單個局部方向的各向異性圖像。

1.2.35Periodic Noise Removing Filter

學習如何使用傅里葉濾波器去除週期噪聲。

1.3 High Level GUI and Media (highgui module)

主要描述Trackbar 的使用方法

1.4Image Input and Output (imgcodecs module)

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章