中間值濾波 |
尚未結案
|
enher
一般會員 發表:1 回覆:1 積分:0 註冊:2008-11-20 發送簡訊給我 |
int left,right,low=0,up,down,i=0,temp;
int sort[9]={0}; Byte *ptr, *tptr,*uptr,*dptr; for(int row = 1 ; row { up=row-1; down=row 1; ptr = (Byte*) Image1->Picture->Bitmap->ScanLine[row]; //原始ptr tptr = (Byte*) Image1->Picture->Bitmap->ScanLine[row]; //mask運算ptr uptr = (Byte*) Image1->Picture->Bitmap->ScanLine[up]; //mask運算ptr dptr = (Byte*) Image1->Picture->Bitmap->ScanLine[down]; //mask運算ptr for(int col = 1 ; col < Image1->Picture->Bitmap->Width-1 ; col ) { left=col-1; right=col 1; i=0; sort[i]=uptr[left]; i ; sort[i]=uptr[col]; i ; sort[i]=uptr[right]; i ; sort[i]=tptr[left]; i ; sort[i]=tptr[col]; i ; sort[i]=tptr[right]; i ; sort[i]=dptr[left]; i ; sort[i]=dptr[col]; i ; sort[i]=dptr[right]; for(int j=0;j<9;j ) { for(int k=j 1;k<9;k ) { if(sort[k] temp=sort[j]; sort[j]=sort[k]; sort[k]=temp; } } } ptr[col]=sort[4]; } } Image1->Refresh(); 以上是小弟寫的中間值濾波 但在執行時 圖片只有變過一次 但我不知道問題出在哪邊 請各位大大幫我解答一下 |
enher
一般會員 發表:1 回覆:1 積分:0 註冊:2008-11-20 發送簡訊給我 |
|
mynameisoa
一般會員 發表:4 回覆:8 積分:2 註冊:2008-10-07 發送簡訊給我 |
[code cpp] int M[9]; //產生一臨時圖像以做Median Graphics::TBitmap *MedianBmp= new Graphics::TBitmap(); MedianBmp->Assign(TempBitmap); for(int y=0;y up =y-1; down =y 1; if(up<0) up = MedianBmp->Height-1; if(down == MedianBmp->Height) down=0; ptr = (Byte*)TempBitmap->ScanLine[y]; tptr = (Byte*)MedianBmp->ScanLine[y]; uptr= (Byte*)MedianBmp->ScanLine[up]; dptr= (Byte*)MedianBmp->ScanLine[down]; for(int x=0;x left = 3*x-1; right= 3*x 1; if(left<0) left = MedianBmp->Width-1; if(right==MedianBmp->Width) right=0; M[0]=(int)uptr[left]; M[1]=(int)uptr[3*x]; M[2]=(int)uptr[right]; M[3]=(int)tptr[left]; M[4]=(int)tptr[3*x]; M[5]=(int)tptr[right]; M[6]=(int)dptr[left]; M[7]=(int)dptr[3*x]; M[8]=(int)dptr[right]; for(int i=0 ; i<9 ; i ){ for(int j=i 1 ; j<9 ; j ){ if(M[i] < M[j]){ tmp = M[i]; M[i] = M[j]; M[j] = tmp; } } } ptr[3*x]=ptr[3*x 1]=ptr[3*x 2]=M[4]; } } delete MedianBmp; [/code] 我想我們寫的差別在掃ScanLine我有另外開一張圖來做遮罩運算... 而你是直接在Image1上做 你這邊改掉看看 |
blk5743
高階會員 發表:34 回覆:371 積分:236 註冊:2003-11-17 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |