我有一个简单的函数,它试图循环遍历单个通道cv::mat中的所有像素。它不能正常工作。我正在iOS SIM卡上的xcode中运行此程序。
cv::mat filledge(cv::mat floaded){
浮点当前颜色=255.0;
cv::size shape=floaded.size();
int h=形状高度;
int w=shape.width;
int计数=1;
对于(int y=0;y!= h;y++){
对于(int x=0;x!{= W;x++){
cv::点2i p(y,x);
浮点型。at<int>(p)=currentcolor;
}
}
std::cout<<fload.channels()<<std::endl;
//印刷品1
std::cout<<fload<<std::endl;
回报浮动;
}
< /代码>
出于某种原因,它会打印一个条纹图像。

在函数返回之前,cv::mat的输出是什么样子的
[255,0,0,0,255,0,0,0,255,0,0,0,0,255,0,0,0,255,
0,0,0,255,0,0,0,255,0,0,0,255,0,0,0,0,0,255,0,
0,0,255,0,0,0,255,0,0,0,255,0,0,0,0,255,0,0,
0,255,0,0,0,255,0,0,0,255,0,0,0,255,0,0,…
< /代码>
cv::Mat fillEdge(cv::Mat floated) {
float currentColor = 255.0;
cv::Size shape = floated.size();
int h = shape.height;
int w = shape.width;
int count = 1;
for(int y = 0; y!= h; y++) {
for(int x = 0; x!= w; x++) {
cv::Point2i p(y, x);
floated.at<int>(p) = currentColor;
}
}
std::cout << floated.channels() << std::endl;
// prints 1
std::cout << floated << std::endl;
return floated;
}
出于某种原因,它会打印条纹图像。

在函数返回之前,cv::mat的输出是什么样子的
[255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255,
0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0,
0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0,
0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, ...