gpt4 book ai didi

c++ - 在没有循环的情况下在opencv::Mat中创建一个矩形零

转载 作者:行者123 更新时间:2023-11-28 02:58:19 24 4
gpt4 key购买 nike

将 opencv::Mat 的特殊 block 设为零的有效方法是什么? (没有循环)

Mat freq;

// Set some frequencies to 0
for (int y=0; y<freq.rows; y++)
{
for (int x=Start; x<freq.cols; x++)
{
if (x>Start || y>Start)
freq.at<double>(y,x) = 0.0;
}
}
// Set some frequencies to 0
for (int y=Start; y<freq.rows; y++)
{
for (int x=0; x<freq.cols; x++)
{
freq.at<double>(y,x) = 0.0;
}
}

最佳答案

试试下面的代码

Mat src;
Mat roi = src(Rect(x,y,width,height)); // Set Roi
roi.setTo(0); // Set all pixel to 0 on both src and roi

关于c++ - 在没有循环的情况下在opencv::Mat中创建一个矩形零,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21495104/

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