选择性搜索算法小结
研究了好久的选择性搜索算法,终于把它搞定!!!
论文
选择性搜索算法的实现包含了两部分,一是图分割算法,二是选择性搜索算法,分别由两篇论文组成:
源码
图分割
图分割论文提供了C++
实现,同时OpenCV
也实现了图分割算法
选择性搜索
选择性搜索算法在OpenCV
中已有实现。为了进一步理解选择性搜索算法的实现,从OpenCV
中抽取了相应的源码进行学习:zjZSTU/selectivesearch
OpenCV bug
当前使用OpenCV 4.2.0
,之前使用过OpenCV 4.0.0/4.1.0
,发现使用selectivesearch
进行目标检测时,如果输入的图像长宽比过大就会出错。在Github
的opencv/opencv_contrib
仓库的Issues
上找到不少的讨论
- Bug in SelectiveSearchSegmentation #705
- SelectiveSearchSegmentation crashes with some image #1707
- Selective Search crashes on images with a width:height or height:width ratio greater than about 2.43 #2102
这个问题已经得到了解决:
其原因是计算方向导数时,需要对图像进行旋转操作,计算梯度后重新旋转回原来的方向,并进行剪切操作。如果图像宽高比过大,会导致裁剪出错
1 | During one of the stages of selective search, the image is rotated 45 degrees and gradients are computed along the X and Y directions in the rotated image. The gradient image is then rotated back to the original orientation and cropped to remove surrounding empty space, leaving it with the same shape as the original image. However, the implementation of the crop will specify an ROI with negative x or y values if the image's native aspect ratio is too high or too low (basically, if the image is far from square). |
小结
选择性搜索算法将目标检测转换成图像分割
- 图分割算法将图像分割的过程转换成图分量合并的过程
- 选择性搜索算法对初始分割集进行分层分组算法,进一步合并得到更多的候选区域