| 
 
| 求看这那错了,编译没错,但运行后显示内存不足什么的? #include <stdio.h>
 #include <iostream.h>
 #include <iomanip.h>
 #include <cstdlib>
 #include <ctime>
 
 void main()
 {
 int TempH=3;
 int TempW=3;
 int TempCX=1;
 int TempCY=1;
 int m_imgWidth=14;
 int m_imgHeight=14;
 int lineByte =14;
 int tempLen=TempW*TempH;
 int  m_pImgData[14][14];
 unsigned char* m_pImgDataOut,* pDst,* pSrc;
 float value,valuen;
 
 //申请缓冲区
 m_pImgDataOut=new unsigned char[lineByte*m_imgHeight];
 
 //生成随机的数组并显示
 srand((unsigned)time(NULL));
 
 for(int c=0;c<14;c++){
 for(int d=0;d<14;d++){
 m_pImgData[c][d]=rand()%255;
 }
 }
 
 for(int g=0;g<14;g++){
 for(int f=0;f<14;f++){
 cout<<setw(5)<<m_pImgData[g][f];
 
 }
 cout<<endl;
 }
 
 //进行3*3模板处理
 int i,j,k,l;
 //行处理(去掉边缘几行)
 for ( i = TempCY; i < m_imgHeight - TempH + TempCY + 1; i++)
 {
 //列处理(去掉边缘几列)
 for ( j = TempCX; j < m_imgWidth - TempW + TempCX + 1; j++)
 {
 
 //模板数组
 for (int k = 0; k < TempH; k++)
 {
 for (int l = 0; l < TempW; l++)
 {
 value+=m_pImgData[i-TempCY+k][j-TempCX+l];
 }
 }
 
 valuen=value/9;
 
 //局部二值化
 for(int m=0;m<TempH;m++)
 {
 for(int n=0;n<TempW;n++)
 {
 pDst=m_pImgDataOut + lineByte * (m_imgHeight - 1 - i+TempCY-m) + j-TempCX+n;
 if(*pSrc<valuen)
 *pDst=0;
 else
 *pDst=255;
 }
 }
 }
 }
 }
 | 
 |