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/