【问题标题】:Local maximas with C++/OpenCV使用 C++/OpenCV 的局部最大值
【发布时间】:2018-06-30 08:05:51
【问题描述】:

我正在尝试使用 OpenCv 和 C++ 实现 Harris 角点检测器,但我似乎找不到找到局部最大值的算法,我是图像处理的新手,请你帮帮我吗?

【问题讨论】:

    标签: c++ algorithm opencv image-processing corner-detection


    【解决方案1】:

    取一个 3x3 的窗口,然后检查中心像素是否为最大值

    我发现我经常从我的二进制图像库中回收这个函数 https://github.com/MalcolmMcLean/binaryimagelibrary/

    /*
      get 3x3 neighbourhood, padding for boundaries
      Params: out - return pointer for neighbourhood
              binary - the binary image
              width - image width
              height - image height
              x, y - centre pixel x, y co-ordinates
              border - value to pad borders with.
      Notes: pattern returned is
                 0  1  2
                 3  4  5
                 6  7  8
             where 4 is the pixel at x, y.
    */
    static void get3x3(unsigned char *out, unsigned char *binary, int width, int height, int x, int y, unsigned char border)
    {
        if(y > 0 && x > 0)        out[0] = binary[(y-1)*width+x-1]; else out[0] = border;
        if(y > 0)                 out[1] = binary[(y-1)*width+x];   else out[1] = border;
        if(y > 0 && x < width-1)  out[2] = binary[(y-1)*width+x+1]; else out[2] = border;
        if(x > 0)                 out[3] = binary[y*width+x-1];     else out[3] = border;
                                  out[4] = binary[y*width+x];
        if(x < width-1)           out[5] = binary[y*width+x+1];     else out[5] = border;
        if(y < height-1 && x > 0) out[6] = binary[(y+1)*width+x-1]; else out[6] = border;
        if(y < height-1)          out[7] = binary[(y+1)*width+x];   else out[7] = border;
        if(y < height-1 && x < width-1) out[8] = binary[(y+1)*width+x+1]; else out[8] = border; 
    }`
    

    ` 您可能需要将 unsigned char 更改为 int 或 float - 该函数是为二进制图像设计的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-07-29
      • 1970-01-01
      • 2022-01-12
      • 1970-01-01
      • 2012-05-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多