此代码中的错误超出范围
error in this code out of range
可能的重复项:
计数像素坐标 x 和 y
我正在尝试使用此代码来对像素坐标值进行求和
这是代码
#include<cv.h>
#include<cvaux.h>
#include<highgui.h>
#include<iostream>
#include<cxtypes.h> // for cvarr
using namespace std;
void main()
{
IplImage* image;
int w,h;
char* filename;
filename="D:\Recognition\Image Crop\7.jpg";
image=cvLoadImage(filename,0); //load image from file
// Get image attribute
w=image->width; //image width
h=image->height; //image height
cout<<"1. image width "<<w<<"n2. image height "<<h<<" n";
int Sx,Sy;
const CvArr* arr; // msh 3arf aih lzmtha
CvScalar se; // to store the num
//loop 3shan 23di 3ala kol pixel
for(int x=0;x<image->width;x++)
{
for(int y=0;y<image->height;y++)
{
se=cvGet2D(image,x,y);
Sx=se.val[y];
Sx+=Sx;
}
Sy=se.val[x];
Sy+=Sy;
}
cout<<"1. image width "<<w<<"n2. image height "<<h<<" n";
cout<<"3. sum x ="<<Sx<<"n4. sum y ="<<Sy<<" n";
}
此代码用于计数或获取图像中 x 和 y 的像素 P(x,y) 总和
这个输出是宽度和高度的值,但不要计算 x 和 y 的值并在输出屏幕中超出范围
任何帮助
提前谢谢.
Sx=se.val[y];
Sx+=Sx;
这不是在做你认为它正在做的事情。
a += b;
与a = a+b;
相同:在每次迭代中,您都会覆盖Sx
的值,然后将其添加到自身(加倍)并将该值存储回Sx
变量中。 (在下一次迭代时覆盖它的位置。
相关文章:
- "myClock"未在此范围错误中声明
- 包含来自另一个文件的函数会导致范围错误(openFoam)
- Visual C:命名空间范围错误或晦涩功能?
- 在遍历字符串时,为什么我没有超出范围错误,即使我已经超出了它的长度?
- 此范围错误中未声明如何修复
- 尝试声明函数的局部变量,但得到范围错误
- c ++ to_string未在此范围错误 [Windows + Devcpp 环境] 中声明
- 将文件读取到向量的向量,超出范围错误
- 向量下标出的范围错误.即使向量的索引大于访问数据的索引,也会发生误差
- Eratosthenes C 的筛子 - 内存处的范围错误
- 向量:内存处的范围错误
- 测试完美哈希函数时超出范围错误
- 为什么此代码会给出 Vector 超出范围错误
- 在填充 Arduino 草图时出现范围错误
- 如何修复C++中矢量的"下标超出范围"错误?
- CPP-模板范围错误
- 在此范围错误中未声明函数错误
- C 表达式:向量下标出范围错误线:1733
- 无法在好友函数中实例化类?我没有得到在范围错误中声明
- 带有类的嵌套结构.范围错误