小编cka*_*ain的帖子

赋值给*这个(*this = val)是什么?

我正在浏览Qt资源,并注意到了这一点

QUuid &operator=(const GUID &guid)
{
    *this = QUuid(guid);
    return *this;
}
Run Code Online (Sandbox Code Playgroud)

我以前从没见过"这个"的作业.赋予"this"的作用是什么?

c++ qt this

7
推荐指数
1
解决办法
2766
查看次数

C++ 11基于范围的auto for value for value,reference和pointer

我知道如何在for循环中使用auto关键字来按值或引用迭代这个数组.

struct A {
 void fun() {};
};

int main() {
  A a[2];

  // Value
  for (auto x : a) {
    x.fun();
  }

  // Ref
  for (auto& x : a) {
    x.fun();
  }

  // Pointer
  //for (...) {
    x->fun();
  }
}
Run Code Online (Sandbox Code Playgroud)

所以我正在寻找这个约定的第三个版本.我如何在这里使用指针?

c++ for-loop auto c++11

7
推荐指数
2
解决办法
3784
查看次数

有效地实施侵蚀/扩张

因此通常使用四个for循环来实现通常且非常低效的最小/最大过滤器.

for( index1 < dy ) { // y loop
    for( index2 < dx ) { // x loop
        for( index3 < StructuringElement.dy() ) { // kernel y
            for( index4 < StructuringElement.dx() ) { // kernel x
                pixel = src(index3+index4);
                val = (pixel > val) ? pixel : val; // max
            }
        }
        dst(index2, index1) = val;
    }
}
Run Code Online (Sandbox Code Playgroud)

然而,这种方法效率很低,因为它再次检查先前检查的值.所以我想知道在下一次迭代中使用先前检查的值来实现这个的方法是什么?

可以对结构元素大小/原点进行任何假设.

更新:我特别渴望了解这种或某种实现的任何见解:http://dl.acm.org/citation.cfm?id = 2114689

algorithm math filtering convolution computer-vision

6
推荐指数
2
解决办法
4559
查看次数

标签 统计

c++ ×2

algorithm ×1

auto ×1

c++11 ×1

computer-vision ×1

convolution ×1

filtering ×1

for-loop ×1

math ×1

qt ×1

this ×1