BMP檔分區(64*64)計算MEAN |
尚未結案
|
iii0628
一般會員 發表:50 回覆:46 積分:19 註冊:2005-04-04 發送簡訊給我 |
我現在要將一張BMP分成數個 64*64大小的區塊 再計算每一個區塊的MEAN值之後比較大小,最後將MEAN值最高的那一個區塊的MEAN值顯示在Label元件上。
計算整張BMP MEAN值的程式我已經寫了,接下來要怎麼改一直沒有頭緒。
Image1->Picture->Bitmap->PixelFormat = pf24bit; byte *ptr1=NULL; int k=0; b1=new double [Image1->Picture->Height*Image1->Picture->Width*3]; for (int i=0;i這是我爬了一下文找到的,但是照這寫法我有64*64,要一個一個寫的話我會發 瘋的 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內取平均灰階值 } }發表人 - iii0628 於 2005/06/24 14:45:21 |
JerryKuo
版主 發表:42 回覆:571 積分:322 註冊:2003-03-10 發送簡訊給我 |
iii0628你好: 應該沒有想像的這麼難...我用c語言寫的,參考看看
int** MainFunction(int** image,int width, int height) { int i,j,x,y,m,l; int **mean = NULL; int blocksize = 64; int mean_width = (int)width/blocksize, mean_height= (int)height/blocksize; if( mean_width*blocksize != width ) { printf("Image can't be divided with no remainder\n"); return NULL; } //---------Build a array to save mean --------- mean = (int **)malloc(sizeof(int *)*mean_height); for(j = 0; j < mean_height; j ) { mean[j] = new int[mean_width]; for(i = 0; i < mean_width; i ) mean[j][i] = 0; } //-------------------------------------------- for(j=0,y=0;j |
iii0628
一般會員 發表:50 回覆:46 積分:19 註冊:2005-04-04 發送簡訊給我 |
JerryKuo你好:請問這程式是用來區分64*64區塊的嗎???有點不懂可以請你解
釋一下嗎???謝謝
引言: iii0628你好: 應該沒有想像的這麼難...我用c語言寫的,參考看看int** MainFunction(int** image,int width, int height) { int i,j,x,y,m,l; int **mean = NULL; int blocksize = 64; int mean_width = (int)width/blocksize, mean_height= (int)height/blocksize; if( mean_width*blocksize != width ) { printf("Image can't be divided with no remainder\n"); return NULL; } //---------Build a array to save mean --------- mean = (int **)malloc(sizeof(int *)*mean_height); for(j = 0; j < mean_height; j ) { mean[j] = new int[mean_width]; for(i = 0; i < mean_width; i ) mean[j][i] = 0; } //-------------------------------------------- for(j=0,y=0;j |
JerryKuo
版主 發表:42 回覆:571 積分:322 註冊:2003-03-10 發送簡訊給我 |
|
iii0628
一般會員 發表:50 回覆:46 積分:19 註冊:2005-04-04 發送簡訊給我 |
|
JerryKuo
版主 發表:42 回覆:571 積分:322 註冊:2003-03-10 發送簡訊給我 |
|
limeca
中階會員 發表:2 回覆:74 積分:60 註冊:2005-05-11 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |