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

影像高通濾波

答題得分者是:istillloving
noodlejay
一般會員


發表:8
回覆:18
積分:10
註冊:2011-08-10

發送簡訊給我
#1 引用回覆 回覆 發表時間:2011-09-20 01:46:52 IP:163.28.xxx.xxx 訂閱
小弟照著找到的3X3遮罩去寫,有中間的像素直*9剪掉周圍的像素

做出來的結果好像不太一樣,所以拿出來跟大家討論看看
並附上檔案及圖片,01是範例程式的結果,02是我自己執行的結果

以下是我使用到的.h檔
[code cpp]
//---------------------------------------------------------------------------
#ifndef TCColorH
#define TCColorH
struct TCColor
{
union
{
TColor Color;
struct
{
unsigned char Red;
unsigned char Green;
unsigned char Blue;
unsigned char Reserved;
};
};
TCColor(TColor c):Color(c){}
TCColor(unsigned char R, unsigned char G, unsigned char B):
Red(R), Green(G), Blue(B), Reserved(0){}
};
//---------------------------------------------------------------------------
#endif

[/code]


高通部分的程式

[code cpp]
Graphics::TBitmap *TempBitmap;//宣告兩個指標*TheBitmap,*TempBitmap
//TempBitmap=new Graphics::TBitmap();
TempBitmap=Image1->Picture->Bitmap;

int x,y,highpass;
for(y=1;y<=TempBitmap->Height-1;y )
{
for(x=1;x<=TempBitmap->Width-1;x )
{
TCColor a1=TempBitmap->Canvas->Pixels[x-1][y-1]; //1
TCColor a2=TempBitmap->Canvas->Pixels[x][y-1];
TCColor a3=TempBitmap->Canvas->Pixels[x 1][y-1];
TCColor a4=TempBitmap->Canvas->Pixels[x-1][y];
TCColor a5=TempBitmap->Canvas->Pixels[x][y];
TCColor a6=TempBitmap->Canvas->Pixels[x 1][y];
TCColor a7=TempBitmap->Canvas->Pixels[x-1][y 1];
TCColor a8=TempBitmap->Canvas->Pixels[x][y 1];
TCColor a9=TempBitmap->Canvas->Pixels[x 1][y 1];

int xx= ((int)a5.Red)*9;
//graylevel=((int)c.Red (int)c.Green (int)c.Blue)/3;
highpass=xx-((int)a1.Red (int)a2.Red (int)a3.Red (int)a4.Red (int)a6.Red (int)a7.Red (int)a8.Red (int)a9.Red);

//Memo1->Lines->Add(IntToStr((int)a5.Red));
//Memo1->Lines->Add(IntToStr(xx));


if(highpass>255)
{
highpass=255;
}
if(highpass<0)
{
highpass=0;
}
Image1->Canvas->Pixels[x][y]=TCColor(highpass,highpass,highpass).Color;
}
}

ShowMessage("Operation is done!");
[/code]


附加檔案:4e77800c7629a_00.rar
編輯記錄
noodlejay 重新編輯於 2011-09-19 21:38:10, 註解 無‧
istillloving
高階會員


發表:33
回覆:182
積分:183
註冊:2008-10-09

發送簡訊給我
#2 引用回覆 回覆 發表時間:2011-10-11 12:26:53 IP:59.120.xxx.xxx 訂閱
感覺上是你沒有把處理完的影像暫存起來
而是直接覆寫原始影像 導致資訊錯誤
------
恩...
系統時間:2024-04-27 2:53:19
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!