線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:1287
推到 Plurk!
推到 Facebook!

多階Harr小波轉換 有更快的寫法嗎

尚未結案
swindler
一般會員


發表:13
回覆:22
積分:17
註冊:2003-01-08

發送簡訊給我
#1 引用回覆 回覆 發表時間:2004-05-24 07:11:14 IP:140.122.xxx.xxx 未訂閱
小弟友執行效率上的困惱 想請問各位大大有更精簡的寫法嗎    
 
//主程式 多階Harr
void DWTImage_Haar(short int **img,int Height,int Width,int Layer)
{
  for(int i=0;i<Layer;i  )
  {
    HOR_SD_Short(img,Height,Width);
    VER_SD_Short(img,Height,Width);
    Height = Height >> 1;
    Width = Width >> 1;
  }
}    //--------2D horizontal sub-band decomposition
// img: input image
// Height: image height;    N: image width      N even;
static void HOR_SD_Short(short int **img,int Height,int N)
{
  short int *y=NULL, *x=NULL;
    /* allocate memory for y */
  int size=N*sizeof(short int);
  if ((y = (short int *) malloc(size)) == NULL)
  {
     printf("Not enough memory to allocate buffer\n");
     exit(1);  /* terminate program if out of memory */
  }
  register int i=0,j=0,k=0;
  int h=N>>1;
  for(k=0;k>1;
  for(k=0;k>1;
      *(*(x h i) k)=(*(y j)-*(y j 1))>>1;
    }
  }
  free(y);
}    
承蒙指教 不勝感激
pwipwi
版主


發表:68
回覆:629
積分:349
註冊:2004-04-08

發送簡訊給我
#2 引用回覆 回覆 發表時間:2004-05-25 03:53:43 IP:211.76.xxx.xxx 未訂閱
swindler你好: HOR_SD_Short和VER_SD_Short在呼叫malloc上一共重複了2*Layer次,如果改成在DWTImage_Haar一次就直接配置最大的size。再傳給HOR_SD_Short和VER_SD_Short,那就只要呼叫一次的malloc。不過如果Layer不大的話,就沒什麼差別了。
系統時間:2024-07-01 6:17:09
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!