這是我的中值濾波的代碼 就是搞不懂自適應怎么做
void __fastcall TForm1::N24Click(TObject *Sender)
{
Screen->Cursor=crHourGlass;
Byte red[9],green[9],blue[9];
for(int i=1;i<m_Height-1;++i)
{for(int j=1;j<m_Width-1;++j)
{red[0]=m_RedData[i-1][j-1];
red[1]=m_RedData[i-1][j];
red[2]=m_RedData[i-1][j+1];
red[3]=m_RedData[i][j-1];
red[4]=m_RedData[i][j];
red[5]=m_RedData[i][j+1];
red[6]=m_RedData[i+1][j-1];
red[7]=m_RedData[i+1][j];
red[8]=m_RedData[i+1][j+1];
green[0]=m_GreenData[i-1][j];
green[1]=m_GreenData[i-1][j-1];
green[2]=m_GreenData[i-1][j+1];
green[3]=m_GreenData[i][j-1];
green[4]=m_GreenData[i][j];
green[5]=m_GreenData[i][j+1];
green[6]=m_GreenData[i+1][j-1];
green[7]=m_GreenData[i+1][j];
green[8]=m_GreenData[i+1][j+1];
blue[0]=m_BlueData[i-1][j-1];
blue[1]=m_BlueData[i-1][j];
blue[2]=m_BlueData[i-1][j+1];
blue[3]=m_BlueData[i][j-1];
blue[4]=m_BlueData[i][j];
blue[5]=m_BlueData[i][j+1];
blue[6]=m_BlueData[i+1][j-1];
blue[7]=m_BlueData[i+1][j];
blue[8]=m_BlueData[i][j];
qsort(red,9,1,Compare);
qsort(green,9,1,Compare);
qsort(blue,9,1,Compare);
m_TempRedData[i][j]=abs(red[5]);
m_TempGreenData[i][j]=abs(green[5]);
m_TempBlueData[i][j]=abs(blue[5]); }}
RGBColor* lpColor;
for(int i=0;i<m_Height;++i)
{
lpColor=(RGBColor*)m_pBitmap->ScanLine[i];
for(int j=0;j<m_Width;++j)
{
(lpColor+j)->Red=m_TempRedData[i][j];
(lpColor+j)->Green=m_TempGreenData[i][j];
(lpColor+j)->Blue=m_TempBlueData[i][j];
}
}
Image1->Canvas->Draw(0,0,m_pBitmap);
Screen->Cursor=crDefault;
}
uj5u.com熱心網友回復:
是適應幅度大小嗎?轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/67642.html
標籤:基礎類
