opencv - 如何沿线提取强度分布图?

标签 opencv image-processing

OpenCV中是否有一个开箱即用的函数可以从图像中沿一条线提取强度轮廓,就像MATLAB中的 improfile 函数一样?

最佳答案

是的,它称为LineIterator。

// grabs pixels along the line (pt1, pt2)
// from 8-bit 3-channel image to the buffer
LineIterator it(img, pt1, pt2, 8);
LineIterator it2 = it;
vector<Vec3b> buf(it.count);
for(int i = 0; i < it.count; i++, ++it)
    buf[i] = *(const Vec3b*)*it;
// alternative way of iterating through the line
for(int i = 0; i < it2.count; i++, ++it2)
{
    Vec3b val = img.at<Vec3b>(it2.pos());
    CV_Assert(buf[i] == val);
}

更多信息在这里:

https://docs.opencv.org/master/dc/dd2/classcv_1_1LineIterator.html

关于opencv - 如何沿线提取强度分布图?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58815465/

相关文章:

c++ - OpenCV Visual Studio ntdll.dll

c++ - 在 C++ 中将 RGB 格式转换为 HDR 图像格式(EXR 格式)

python - 如何提高图像质量?

matlab - 频谱图及其含义

visual-studio-2008 - 缺少 cxcore110d.dll?

c++ - 根据标记点对齐 2 张人脸图像

python - 如何使用python定位和读取Data Matrix代码

python - 如何更快地处理nparrays

c++ - 使用 Ferns 描述符训练后保存 opencv 描述符匹配器

matlab - 在matlab中定义掩码的代码