2012-04-04 194 views
0

我們在圖像處理項目中使用Blodshed Dev-C++。我們正在視頻幀上實施連接組件標籤。我們必須使用遞歸函數遞歸很多次以至於我們得到一個計算器。我們如何能有更大的堆棧大小?是否有可能通過一些鏈接器參數或類似的東西來改變它?如何在Bloodshed Dev-C++中增加堆棧大小?

void componentLabel(int i,int j,IplImage *img){ 
    // blueFrame = img->imageData[i*3*width+j*3]; 
//  greenFrame = img->imageData[i*3*width+j*3+1]; 
//  redFrame = img->imageData[i*3*width+j*3+2]; 

    if(!(img->imageData[i*3*width+j*3]==0 && img->imageData[i*3*width+j*3+1]==0 && img->imageData[i*3*width+j*3+2]==0) ){ 
      //printf("iffffff aq\n"); 
      return;  
    } 
    else{ 
      //printf("else aq %d\n",sayac_label);       
       img->imageData[i*3*width+j*3]=1; 

       new_object.pixel_count=new_object.pixel_count+1; 
       new_object.total_row=new_object.total_row+i; 
       new_object.total_col=new_object.total_col+j; 

       if(j<width-1){     
         componentLabel(i,j+1,img);       
       }    
       if(j>0){     
         componentLabel(i,j-1,img);     
       }    
       if(i<height-1){ 
         if(i>new_object.bottom.satir){ 
           new_object.bottom.satir=i; 
           new_object.bottom.sutun=j;            
         } 

         componentLabel(i+1,j,img);       
       }    
       if(i>0){ 
         if(i<new_object.top.satir){ 
           new_object.top.satir=i; 
           new_object.top.sutun=j;            
         }     
         return componentLabel(i-1,j,img);    
       }  
    } 
+0

請告訴我你使用的是最新版本的DevC++而不是5年前的版本。 – Mysticial 2012-04-04 19:48:16

+0

dev-C++ 4.9.9.2 – 2012-04-04 19:49:56

+0

facepalm ....... – Mysticial 2012-04-04 19:51:11

回答

1

只有一個辦法將保證你不會用完堆棧大小 - 重新制定的算法是尾遞歸(並確保你的編譯器優化尾調用 - 通常是-O3(或-02? )優化標誌)。

簡而言之,您是否增加了shell授予您的任務的最大堆棧大小?

ulimit -s <maximum stack size>