int ii=55;
FILE *fp;
unsigned int flen,datalen;
char buf[80];
sprintf(buf, "D:\\light_test\\t2\\%d.bmp", ii);
fp=fopen(buf,"r");
fseek(fp,0L,SEEK_END);
flen=ftell(fp);
//datalen=flen-(14+40+256*4);
datalen=flen-1078;
fseek(fp,1078,SEEK_SET);
FILE *fp;
unsigned int flen,datalen;
char buf[80];
sprintf(buf, "D:\\light_test\\t2\\%d.bmp", ii);
fp=fopen(buf,"r");
fseek(fp,0L,SEEK_END);
flen=ftell(fp);
//datalen=flen-(14+40+256*4);
datalen=flen-1078;
fseek(fp,1078,SEEK_SET);
unsigned char *buffer = new unsigned char[datalen];
fread(buffer,1,datalen,fp);
fclose(fp);
灰度图的灰度值就在buffer中了
int I1[width][length];
int I2[width][length];
for(int i=0;i<width;i++)
{
for(int j=0;j<length;j++)
{
I[i][j]=*(buffer+i*j+j);
}
}
delete buffer;
以上将buffer中的数据保存在二维数组中了
1万+

被折叠的 条评论
为什么被折叠?



