简体   繁体   English

OpenCV /图像处理技术,用于查找图像中亮点的中心

[英]OpenCV / Image Processing techniques to find the centers of bright spots in an image

I'm currently doing a project based on the methodology described in this paper: Camera calibration from a single night sky image 我目前正在做一个基于本文所述方法的项目: 从单个夜空图像中进行摄像机校准

As a beginner in computer vision, I do not quite understand how I can implement the method used in the paper to find the centre of all the bright spots (luminaries) within an image, particular on the paragraph in section 4.1: 作为计算机视觉的初学者,我不太明白如何实现本文中使用的方法来找到图像中所有亮点(灯具)的中心,特别是4.1节中的段落:

The surrounding patch of size 15 × 15 pixels (Figure 1(a)), is upsampled by a given factor (Figure 1(c)) and the corresponding gradient map is calculated (Figure 1(d)). 大小为15×15像素的周围斑块(图1(a))由给定因子(图1(c))上采样,并计算相应的梯度图(图1(d))。 Starting from the brightest region, the gray value threshold is decreased, until an energy function is maximized. 从最亮区域开始,降低灰度值阈值,直到能量函数最大化。 The energy function is defined as the sum of the border gradients and normalized by the border length (Figure 1(e)). 能量函数定义为边界梯度的总和,并通过边界长度标准化(图1(e))。 This leads to a segmented star image shown in Figure 1(f). 这导致图1(f)中所示的分段星形图像。 The segmentation ensures that the weighted centre of gravity algorithm [11] gives a robust estimation. 分割确保加权重心算法[11]给出稳健的估计。

上采样图像应用渐变功能后在能量函数应用分段图像之后

From my understanding, I think I can do a Laplacian / Sobel gradient function on the upsampled image, but after that I'm not too sure how I can perform the energy function part and produce the segmented image. 根据我的理解,我认为我可以对上采样图像执行拉普拉斯/索贝尔梯度函数,但之后我不太确定如何执行能量函数部分并生成分割图像。 Also I would also want to understand how implement the weighted centre of gravity algorithm to find the centre of the bright spot using openCV or other python library. 另外我还想了解如何使用openCV或其他python库实现加权重心算法来找到亮点的中心。

Much appreciated if any of you can provide some lights on this. 非常感谢,如果你们中的任何一个人可以为此提供一些灯光。

Thanks and regards. 感谢致敬。

The main thing to take away is energy function used in this context is any function that is used for a maximization problem. 要带走的主要内容是在此上下文中使用的energy function是用于最大化问题的任何函数。 Here, the energy function is the sum of gradients/derivatives/differences (ie "detected borders likelihood" in this case). 这里,能量函数是梯度/导数/差异的总和(即,在这种情况下“检测到的边界可能性”)。

Since you seem to have a non-algorithmic background, I suggest you to read on breadth-first search (remember an image is a very specific type of graph, where every edge is a pixel, connected to adjacent ones), recursion , and floodfill . 由于您似乎有非算法背景,我建议您阅读广度优先搜索 (记住图像是一种非常特殊的图形类型,其中每个边都是像素,连接到相邻的图像), 递归填充

  1. Up/downscale the image 向上/向下缩放图像
  2. Run horizontal and vertical Sobel filters. 运行水平和垂直Sobel滤波器。 Combine the resultant images into grad_img = max_per_pixel(sobel_horiz,sobel_vert). 将结果图像组合成grad_img = max_per_pixel(sobel_horiz,sobel_vert)。
  3. For each 15x15 pixel patch, find the brightest spot. 对于每个15x15像素的补丁,找到最亮的点。 This is the seed of the star. 这是明星的seed
  4. Start from a 1x1 region that consists of the seed . 从包含seed的1x1 region开始。 Keep adding adjacent pixels to that region (recommend breadth-first traversal). 继续向该region添加相邻像素(建议使用广度优先遍历)。 Calculate the energy by the sum of pixel values in grad_img with pixel coordinates the borders of the region . 通过grad_img的像素值之和以及该region边界的像素坐标来计算能量。 If the energy is higher than the energy of the previous iteration, the new pixel is added to the region . 如果能量高于前一次迭代的能量,则将新像素添加到该region If not, the pixel is rejected. 如果不是,则拒绝该像素。
  5. Finding the center of gravity of a closed contour or a collection of pixels is not a hard task. 找到闭合轮廓或像素集合的重心并不是一项艰巨的任务。 Either do it by its math definition (the sum of x and y coordinates of all the in-region pixels, divided by the area), or do it by using the image moments (cv::moments example ). 要么通过它的数学定义(所有区域内像素的x和y坐标之和除以区域),要么通过使用图像矩(cv :: moments 示例 )来做到这一点。

My solution is a bit different than their solution. 我的解决方案与他们的解决方案略有不同。 They actually run a floodfill algorithm that fills all pixels of brightness [threshold;255], calculating energy func, decreasing the threshold, rinse and repeat, stopping when they maximize the energy function. 它们实际上运行填充算法,填充所有像素的亮度[阈值; 255],计算能量函数,降低阈值,冲洗和重复,在最大化能量函数时停止。 Note that their algorithm is very inefficient as they are making effectively up to 255 floodfills for every pre-detected star compared to 1 floodfill in my proposal, and that could be a performance issue in practice. 请注意,他们的算法非常低效,因为与我的提案中的1次填充相比,每个预先检测到的恒星有效地进行了多达255次的填充,这在实践中可能是性能问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM