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

為什麼我的程式效率這麼慢阿

尚未結案
finalevil
一般會員


發表:20
回覆:17
積分:7
註冊:2004-04-13

發送簡訊給我
#1 引用回覆 回覆 發表時間:2004-07-04 07:51:38 IP:218.168.xxx.xxx 未訂閱
詳細內容及程式檔案都在以下連結 http://delphi.ktop.com.tw/topic.php?TOPIC_ID=52637 請各位大大幫忙喔 感激不盡阿...
auslk
初階會員


發表:35
回覆:77
積分:32
註冊:2003-02-17

發送簡訊給我
#2 引用回覆 回覆 發表時間:2004-07-10 15:35:35 IP:61.219.xxx.xxx 未訂閱
您好!  以下程式是由您ㄉ程式擷取出來的     建議您改作ScanLine做法     *只要是圖形(像)處理 一定要用ScanLine方式速度才會快     以上           給我ScanLine,其餘免談 >.<~       
 
ColorFiliter();        int H = Image->Picture->Bitmap->Height;
    int W = Image->Picture->Bitmap->Width;        for(int y=0;yCanvas->Pixels[x][y] = (TColor)RGB(tempdata[y][x].R,tempdata[y][x].G,tempdata[y][x].B);
        }   
finalevil
一般會員


發表:20
回覆:17
積分:7
註冊:2004-04-13

發送簡訊給我
#3 引用回覆 回覆 發表時間:2004-07-18 23:01:51 IP:218.168.xxx.xxx 未訂閱
那個auslk大大..不好意思喔,前幾天回家了所以那麼晚才回 那個我想請問一下 scanline好像只能用來讀出資料不能寫入資料ㄝ 我在讀出一個Image的data時有用scanline,如下
 
 for(int x=0;xRGBdata[x], this->Image->Picture->Bitmap->ScanLine[x],sizeof(RGBA)*(W));    
可是要怎樣才能將資料從陣列中寫入Image裡呢
 
 for(int x=0;xImage->Picture->Bitmap->ScanLine[x], this->RGBdata[x],sizeof(RGBA)*(W));
這樣寫好像怪怪的ㄝ...< > 麻煩大大囉...謝謝< >
auslk
初階會員


發表:35
回覆:77
積分:32
註冊:2003-02-17

發送簡訊給我
#4 引用回覆 回覆 發表時間:2004-07-19 17:07:26 IP:61.219.xxx.xxx 未訂閱
先將圖片轉到矩陣內 再取出來到Image2->Picture    以下是副程式,你可以參考一下!      
 
//-------影像轉到矩陣儲存------------------------------------------------------    void image_to_array(TImage * Image1, int *f)
{
  int x, y;
  int h = Image1->Picture->Height;
  int w = Image1->Picture->Width;
  Byte *ptr;
  for(y = 0; y < h; y  )
  {
    ptr = (Byte *) Image1->Picture->Bitmap->ScanLine[y];
    for(x = 0; x < w * 3; x = x   3)
    {          f[x   3 * w * y] = (int)ptr[x];   // 將圖片的pixel依序填入 陣列
      f[x   1   3 * w * y] = (int)ptr[x   1];
      f[x   2   3 * w * y] = (int)ptr[x   2];        }
  }
}    //-------矩陣轉到影像------------------------------------------------------
void array_to_image(int *g, TImage * Image2)
{
  int x, y;
  Byte *ptr;
  int h = Image2->Picture->Height;
  int w = Image2->Picture->Width;      for(y = 0; y < h; y  )
  {
    ptr = (Byte *) Image2->Picture->Bitmap->ScanLine[y];
    // 取得圖片第 y
    // 軸的起始位置
    for(x = 0; x < w * 3; x = x   3)
    {
      ptr[x   2] = (Byte) g[x   3 * w * y];     // 將陣列的pixel依序填入圖片
      ptr[x   1] = (Byte) g[(x   1)   3 * w * y];
      ptr[x] = (Byte) g[(x   2)   3 * w * y];
    }
  }
}
finalevil
一般會員


發表:20
回覆:17
積分:7
註冊:2004-04-13

發送簡訊給我
#5 引用回覆 回覆 發表時間:2004-07-19 19:51:07 IP:218.168.xxx.xxx 未訂閱
引言: ptr = (Byte *) Image2->Picture->Bitmap->ScanLine[y]; // 取得圖片第 y // 軸的起始位置
恩恩..原來Scanline的作用是這個喔! 我原來沒有弄清楚,現在才真的了解 大大謝謝你喔 所以,我發現 < class="code"> for(int x=0;xImage->Picture->Bitmap->ScanLine[x], this->RGBdata[x],sizeof(RGBA)*(W)); 這樣子做事可以的ㄝ... 而且速度果然有差^^" 謝謝你囉auslk大大
junzuo
一般會員


發表:2
回覆:9
積分:2
註冊:2004-05-22

發送簡訊給我
#6 引用回覆 回覆 發表時間:2004-08-12 11:02:01 IP:163.28.xxx.xxx 未訂閱
大大好 ,小弟我剛學影像處理程式設計, 問題如下 ptr = (Byte *) Image1->Picture->Bitmap->ScanLine[y];    以上程式中的 (Byte *)是代表甚麼呢? thanks for answering my question    
JerryKuo
版主


發表:42
回覆:571
積分:322
註冊:2003-03-10

發送簡訊給我
#7 引用回覆 回覆 發表時間:2004-11-12 14:18:07 IP:220.135.xxx.xxx 未訂閱
引言: 大大好 ,小弟我剛學影像處理程式設計, 問題如下 ptr = (Byte *) Image1->Picture->Bitmap->ScanLine[y]; 以上程式中的 (Byte *)是代表甚麼呢? thanks for answering my question < face="Verdana, Arial, Helvetica"> junzuo你好: scanline的定義
 void * ScanLine[int Row] = {read=GetScanline};
scanline的回傳值為(void*)單純一個指標,因為我想要一個byte一個byte讀取 所以強制將回(void*)傳指標轉為(byte*),我們才能用ptr這個指標一個byte 一個byte讀取。這就為何要在scanline的前面加上(byte*)的原因。 如果我想要4個bytes 4個bytes讀取,可宣告一個長整數指標(long*)接受 scanline所回傳的值。這樣就能4個byte 4個byte讀取。
cc12345
一般會員


發表:32
回覆:35
積分:13
註冊:2005-01-24

發送簡訊給我
#8 引用回覆 回覆 發表時間:2005-03-24 14:39:08 IP:61.219.xxx.xxx 未訂閱
請教asulk兄, 如果是8bit圖如何實做, 我做出來的圖很怪, 像是saturated的, 謝謝.    
引言: 先將圖片轉到矩陣內 再取出來到Image2->Picture 以下是副程式,你可以參考一下!
 
//-------影像轉到矩陣儲存------------------------------------------------------    void image_to_array(TImage * Image1, int *f)
{
  int x, y;
  int h = Image1->Picture->Height;
  int w = Image1->Picture->Width;
  Byte *ptr;
  for(y = 0; y < h; y  )
  {
    ptr = (Byte *) Image1->Picture->Bitmap->ScanLine[y];
    for(x = 0; x < w * 3; x = x   3)
    {          f[x   3 * w * y] = (int)ptr[x];   // 將圖片的pixel依序填入 陣列
      f[x   1   3 * w * y] = (int)ptr[x   1];
      f[x   2   3 * w * y] = (int)ptr[x   2];        }
  }
}    //-------矩陣轉到影像------------------------------------------------------
void array_to_image(int *g, TImage * Image2)
{
  int x, y;
  Byte *ptr;
  int h = Image2->Picture->Height;
  int w = Image2->Picture->Width;      for(y = 0; y < h; y  )
  {
    ptr = (Byte *) Image2->Picture->Bitmap->ScanLine[y];
    // 取得圖片第 y
    // 軸的起始位置
    for(x = 0; x < w * 3; x = x   3)
    {
      ptr[x   2] = (Byte) g[x   3 * w * y];     // 將陣列的pixel依序填入圖片
      ptr[x   1] = (Byte) g[(x   1)   3 * w * y];
      ptr[x] = (Byte) g[(x   2)   3 * w * y];
    }
  }
}
系統時間:2024-05-02 12:27:17
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!