Image::Image(unsigned char **m, int h, int w)
{
m=new unsigned char *[h];
for (int x=0;x<h;x++)
{
m[x]=new unsigned char[w];
}
}
void Image::Read(char* ImageName)
{
IplImage* img = cvLoadImage(ImageName, CV_LOAD_IMAGE_GRAYSCALE);
unsigned char *img_data = (unsigned char *)(img->imageData);
int height=img->height;
int width=img->width;
int width_step=img->widthStep;
unsigned char **date;
Image(date,height,width);
int x,y,z=0;
for(x=0;x<height;x++)
{
for(y=0;y<width;y++)
{
date[x][y]=img_data[z];
z++;
}
}
//将一维指针img_data指向的内存中的值写入成员变量二维指针data所指的内存中
//write your code here*/
cvReleaseImage(&img);
}