1
我試試這個代碼圖像計數像素座標x和y
這是
#include<cv.h>
#include<cvaux.h>
#include<stdio.h>
#include<highgui.h>
#include<iostream>
#include<cxtypes.h> // for cvarr
using namespace std;
// This program to count the pixel value in the gray image
void main()
{
IplImage* image;
int w,h;
char* filename;
filename="D:\\Recognition\\Image Crop\\7.jpg";
image=cvLoadImage(filename,0); //for grayscal image
// 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;
CvScalar se; // to store the num
for(int x=0;x>image->width;x++)
{
for(int y=0;image->height;y++)
{
se=cvGet2D(image,x,y);
Sx=se.val[y];
Sx+=Sx;
}
Sy=se.val[x];
Sy+=Sy;
}
cout<<"3. sum x ="<<Sx<<"\n4. sum y ="<<Sy<<" \n";
}
我試圖計算像素的總和的代碼中求和像素座標(X,Y)座標x和y。
預期輸出是多少?實際輸出是多少? – gcbenison
這必須是C++。在C中,一個字符串不能是<< shift操作的最右邊的操作數。 – wildplasser