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

高通濾波問題

缺席
encoref70036
一般會員


發表:29
回覆:47
積分:15
註冊:2011-05-18

發送簡訊給我
#1 引用回覆 回覆 發表時間:2011-10-12 20:51:35 IP:1.168.xxx.xxx 訂閱
我是用這個遮罩 我把中間的值*9減掉其他八個值相加 但是出來的影像錯誤 請問是哪裡出錯了呢
-1 -1 -1
-1 9 -1
-1 -1 -1
[code cpp]
TMDIChild *Child;
Graphics::TBitmap *nBitmap = new Graphics::TBitmap();
Graphics::TBitmap *pBitmap = new Graphics::TBitmap();
Byte *ptr,*aptr,*uptr,*dptr;
int sum1,sum2,sum3,type,up,down,left,right;
Child = (TMDIChild *) ActiveMDIChild;
Child->Image1->Picture->SaveToFile("temp.bmp");
nBitmap->LoadFromFile("temp.bmp");
pBitmap->LoadFromFile("temp.bmp");
DeleteFile("temp.bmp");
for (int y = 0;y < nBitmap->Height;y )
{
up=(y-1);
down=(y 1);
if(up<0) up=0;
if(down>nBitmap->Height-1) down=nBitmap->Height-1;
ptr=(Byte*)nBitmap->ScanLine[y];
aptr = (Byte*)pBitmap->ScanLine[y];
uptr=(Byte*)pBitmap->ScanLine[up];
dptr=(Byte*)pBitmap->ScanLine[down];
for (int x = 0;x < nBitmap->Width;x )
{
left=(x-1);
right=(x 1);
if(left<0) left=0;
if(right>nBitmap->Width-1) right=nBitmap->Width-1;
sum1 = 0;
sum2 = 0;
sum3 = 0;
sum1 = 9*((int)ptr[4*x])-((int)uptr[4*left] (int)uptr[4*x] (int)uptr[4*right]
(int)ptr[4*left] (int)ptr[4*right]
(int)dptr[4*left] (int)dptr[4*x] (int)dptr[4*right]);
sum2 = 9*((int)ptr[4*x 1])-((int)uptr[4*left 1] (int)uptr[4*x 1] (int)uptr[4*right 1]
(int)ptr[4*left 1] (int)ptr[4*right 1]
(int)dptr[4*left 1] (int)dptr[4*x 1] (int)dptr[4*right 1]);
sum3 = 9*((int)ptr[4*x 2])-((int)uptr[4*left 2] (int)uptr[4*x 2] (int)uptr[4*right 2]
(int)ptr[4*left 2] (int)ptr[4*right 2]
(int)dptr[4*left 2] (int)dptr[4*x 2] (int)dptr[4*right 2]);
if (sum1 < 0) sum1 = 0;
else if (sum1 > 255) sum1 = 255;
if (sum2 < 0) sum2 = 0;
else if (sum2 > 255) sum2 = 255;
if (sum3 < 0) sum3 = 0;
else if (sum3 > 255) sum3 = 255;
aptr[4*x] = (Byte)sum1;
aptr[4*x 1] = (Byte)sum2;
aptr[4*x 2] = (Byte)sum3;
}
}
Child->Image1->Picture->Assign(pBitmap);
[/code]
這是出來後的影像

正常的話應該這樣

麻煩大俠了

encoref70036
一般會員


發表:29
回覆:47
積分:15
註冊:2011-05-18

發送簡訊給我
#2 引用回覆 回覆 發表時間:2011-10-13 17:05:16 IP:1.168.xxx.xxx 訂閱
阿~~我抓錯影像了 
uptr=(Byte*)pBitmap->ScanLine[up];
dptr=(Byte*)pBitmap->ScanLine[down];
應該要抓nBitmap的才對

系統時間:2024-04-19 9:47:09
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!