OpenCV中blob的概念以及OpenCV中BLOB特征提取与几何形状分类
文章目录:
我们总会遇到图像处理中的一些模糊的概念,怎么也理不清楚,说知道也知道,说不知道也不知道,就像隔了一层纱,那今天就让我们一起来揭开她神秘的面纱!!!
一、Blob概念理解
1、概念理解 1
blob
: n. /blɒb/ ` 一点,一滴;(颜色的)一小片,斑点
可以直观的理解是
色斑
:就是相同像素组成的一小块,一小块的特征
Blob分析:(Blob Analysis)是对图像中相同像素
的连通域
进行分析,该连通域称为Blob
。经二值化(Binary Thresholding)处理后的图像中色斑可认为是blob。Blob分析工具可以从背景中分离出目标
,并可以计算出目标的数量、位置、形状、方向和大小
,还可以提供相关斑点间的拓扑结构。在处理过程中不是对单个像素逐一分析,而是对图像的行进行操作。图像的每一行都用游程长度编码(RLE)来表示相邻的目标范围。这种算法与基于像素的算法相比,大大提高了处理的速度。
2、概念理解2
首先要了解,什么是blob特征,我们来看下面两幅图片。
直观上来看,blob特征就是一团,一坨东西,它并不一定是圆形的,总之它就是那么一团独立存在的特征
。
二、blob特征提取
1、python
# Standard imports
import cv2
import numpy as np;
# Read image
im = cv2.imread("blob.jpg", cv2.IMREAD_GRAYSCALE)
# Set up the detector with default parameters.
detector = cv2.SimpleBlobDetector()
# Detect blobs.
keypoints = detector.detect(im)
# Draw detected blobs as red circles.
# cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS ensures the size of the circle corresponds to the size of blob
im_with_keypoints = cv2.drawKeypoints(im, keypoints, np.array([]), (0,0,255), cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS)
# Show keypoints
cv2.imshow("Keypoints", im_with_keypoints)
cv2.waitKey(0)
2、C++
using namespace cv;
// Read image
Mat im = imread( "blob.jpg", IMREAD_GRAYSCALE );
// Set up the detector with default parameters.
SimpleBlobDetector detector;
// Detect blobs.
std::vector<KeyPoint> keypoints;
detector.detect( im, keypoints);
// Draw detected blobs as red circles.
// DrawMatchesFlags::DRAW_RICH_KEYPOINTS flag ensures the size of the circle corresponds to the size of blob
Mat im_with_keypoints;
drawKeypoints( im, keypoints, im_with_keypoints, Scalar(0,0,255), DrawMatchesFlags::DRAW_RICH_KEYPOINTS );
// Show blobs
imshow("keypoints", im_with_keypoints );
waitKey(0);
Reference:
1、https://blog.csdn.net/abcd1992719g/article/details/27071273
2、https://blog.csdn.net/liyangblog/article/details/24962313
3、https://cloud.tencent.com/developer/article/1084326
4、https://brightguo.wordpress.com/2016/05/21/blob-detection-using-opencv-python-c/
♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠