选择性搜索算法小结

研究了好久的选择性搜索算法,终于把它搞定!!!

论文

选择性搜索算法的实现包含了两部分,一是图分割算法,二是选择性搜索算法,分别由两篇论文组成:

  1. [译]高效的基于图的图像分割
  2. [译]作用于目标识别的选择性搜索

源码

图分割

图分割论文提供了C++实现,同时OpenCV也实现了图分割算法

  1. 基于图的图像分割-工程源码
  2. 基于图的图像分割-OpenCV源码

选择性搜索

选择性搜索算法在OpenCV中已有实现。为了进一步理解选择性搜索算法的实现,从OpenCV中抽取了相应的源码进行学习:zjZSTU/selectivesearch

OpenCV bug

当前使用OpenCV 4.2.0,之前使用过OpenCV 4.0.0/4.1.0,发现使用selectivesearch进行目标检测时,如果输入的图像长宽比过大就会出错。在Githubopencv/opencv_contrib仓库的Issues上找到不少的讨论

这个问题已经得到了解决:

其原因是计算方向导数时,需要对图像进行旋转操作,计算梯度后重新旋转回原来的方向,并进行剪切操作。如果图像宽高比过大,会导致裁剪出错

1
2
3
4
5
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).

This is because the bounding box of the rotated image is strictly bigger than the original image if the original is sufficiently close to square; but if the original is too "skinny", the bounding box of its rotation will be less tall or wide than the original.

The fix is to threshold the x and y computed for the ROI at 0.

小结

选择性搜索算法将目标检测转换成图像分割

  • 图分割算法将图像分割的过程转换成图分量合并的过程
  • 选择性搜索算法对初始分割集进行分层分组算法,进一步合并得到更多的候选区域
坚持原创技术分享,您的支持将鼓励我继续创作!