gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 16:13:13 24 4
gpt4 key购买 nike

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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com