區塊掃描 |
尚未結案
|
pork
一般會員 發表:15 回覆:13 積分:5 註冊:2003-10-25 發送簡訊給我 |
|
seeing
初階會員 發表:49 回覆:131 積分:41 註冊:2002-11-07 發送簡訊給我 |
引言: 如何把一張圖 灰階512*512 每4*4分成一個block 然後分別掃描每隔區塊並求出每個區塊的平均值您好: byte *ptr[4]; int R, G, B; int Gray[128][128]; for(int y=0;y<512-1;y =4) { ptr[0]=Bitmap->ScanLine[y]; ptr[1]=Bitmap->ScanLine[y 1]; ptr[2]=Bitmap->ScanLine[y 2]; ptr[3]=Bitmap->ScanLine[y 3]; for(int x=0;x<(512-4)*3;x =4*3) { //在4*4內取R的平均值 R = ( ptr[0][x] ptr[0][x 3] ptr[0][x 6] ptr[0][x 9] ptr[1][x] ptr[1][x 3] ptr[1][x 6] ptr[1][x 9] ptr[2][x] ptr[2][x 3] ptr[2][x 6] ptr[2][x 9] ptr[3][x] ptr[3][x 3] ptr[3][x 6] ptr[3][x 9] )/16; //在4*4內取G的平均值 G = ( ptr[0][x 1] ptr[0][x 4] ptr[0][x 7] ptr[0][x 10] ptr[1][x 1] ptr[1][x 4] ptr[1][x 7] ptr[1][x 10] ptr[2][x 1] ptr[2][x 4] ptr[2][x 7] ptr[2][x 10] ptr[3][x 1] ptr[3][x 4] ptr[3][x 7] ptr[3][x 10] )/16; //在4*4內取B的平均值 B = ( ptr[0][x 2] ptr[0][x 5] ptr[0][x 8] ptr[0][x 11] ptr[1][x 2] ptr[1][x 5] ptr[1][x 8] ptr[1][x 11] ptr[2][x 2] ptr[2][x 5] ptr[2][x 8] ptr[2][x 11] ptr[3][x 2] ptr[3][x 5] ptr[3][x 8] ptr[3][x 11] )/16; Gray[x/12][y/4]=(R G B)/3; //在4*4內取平均灰階值 } }寫的不好,請多多指教!! ps.目前沒有BCB,所以可能要麻煩您自己測試了 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |