int SampleMat()
{
for (int c = 0; c != 12; c++)
{
for (int t = 0; t != m; t++)
{
//Load Image
char filename[14] = { 'S', 'a', 'm', 'p', 'l', 'e', '/', 'a' + c, '0' + t, '.', 'b', 'm', 'p' };
IplImage* pImage = cvLoadImage(filename, 1);
//Covert to Gray
IplImage* pImage2 = NULL;
//为什么在这里bug
pImage2 = cvCreateImage(cvSize(pImage->width, pImage->height), IPL_DEPTH_8U, 1);
//pImage2 = cvCreateImage(cvGetSize(pImage), IPL_DEPTH_8U, 1);
cvCvtColor(pImage, pImage2, CV_BGR2GRAY);
//Get histograms of each image and Stored in SampleX and SampleY
GetHisto(pImage2);
for (int i = 0; i != W; i++)
{
if (HistoMatX[i]) SampleX[i][t][c] = HistoMatX[i];
else SampleX[i][t][c] = 0;
}
for (int j = 0; j != H; j++)
{
if (HistoMatY[j]) SampleY[H - 1 - j][t][c] = HistoMatY[j];
else SampleY[j][t][c] = 0;
}
//Release image
cvReleaseImage(&pImage);
cvReleaseImage(&pImage2);
}
}
return 0;
}