- opencv利用指针创建Mat类型矩阵
Mat(Size, type, pointer_to_buffer);
- Mat矩阵的转置:t(),inv()
- 点乘操作:.mul
- 求非零元素的数目:int countNonZero(Mat src)
- 求均值和方差:meanStdDev(src, mean, stddev)
- 求矩阵的最大最小值及索引:minMaxLoc(src, minVal, maxVal, minLoc, maxLoc)
- In many applications, such as calibration or machine learning,when we are done with the calculations, we need to save the results in order to retrieve them in the next executions. For this purpose, OpenCV provides an XML/YAML persistence layer
- findContours函数会改变输入图像
- 绘制目标边缘
Mat performMorphologicalGradient(Mat inputImage, int
morphologyElement, int morphologySize)
{
Mat outputImage, tempImage1, tempImage2;
int morphologyType;
if(morphologyElement == 0)
morphologyType = MORPH_RECT;
else if(morphologyElement == 1)
morphologyType = MORPH_CROSS;
else if(morphologyElement == 2)
morphologyType = MORPH_ELLIPSE;
// Create the structuring element for erosion
Mat element = getStructuringElement(morphologyTy
pe, Size(2*morphologySize + 1, 2*morphologySize + 1),
Point(morphologySize, morphologySize));
// Apply morphological gradient to the image using the structuring element
dilate(inputImage, tempImage1, element);
erode(inputImage, tempImage2, element);
// Return the output image
return tempImage1 - tempImage2;
}
膨胀-->腐蚀-->相减