為什麼我的程式效率這麼慢阿 |
尚未結案
|
finalevil
一般會員 發表:20 回覆:17 積分:7 註冊:2004-04-13 發送簡訊給我 |
|
auslk
初階會員 發表:35 回覆:77 積分:32 註冊:2003-02-17 發送簡訊給我 |
您好!
以下程式是由您ㄉ程式擷取出來的 建議您改作ScanLine做法 *只要是圖形(像)處理 一定要用ScanLine方式速度才會快 以上
給我ScanLine,其餘免談 >.<~
ColorFiliter(); int H = Image->Picture->Bitmap->Height; int W = Image->Picture->Bitmap->Width; for(int y=0;y |
finalevil
一般會員 發表:20 回覆:17 積分:7 註冊:2004-04-13 發送簡訊給我 |
那個auslk大大..不好意思喔,前幾天回家了所以那麼晚才回
那個我想請問一下
scanline好像只能用來讀出資料不能寫入資料ㄝ
我在讀出一個Image的data時有用scanline,如下
for(int x=0;x可是要怎樣才能將資料從陣列中寫入Image裡呢 for(int x=0;x這樣寫好像怪怪的ㄝ...< > 麻煩大大囉...謝謝< > |
auslk
初階會員 發表:35 回覆:77 積分:32 註冊:2003-02-17 發送簡訊給我 |
先將圖片轉到矩陣內 再取出來到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 發送簡訊給我 |
引言: ptr = (Byte *) Image2->Picture->Bitmap->ScanLine[y]; // 取得圖片第 y // 軸的起始位置恩恩..原來Scanline的作用是這個喔! 我原來沒有弄清楚,現在才真的了解 大大謝謝你喔 所以,我發現 < class="code"> for(int x=0;x |
junzuo
一般會員 發表:2 回覆:9 積分:2 註冊:2004-05-22 發送簡訊給我 |
|
JerryKuo
版主 發表:42 回覆:571 積分:322 註冊:2003-03-10 發送簡訊給我 |
引言: 大大好 ,小弟我剛學影像處理程式設計, 問題如下 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 發送簡訊給我 |
請教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]; } } } |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |