Delphi基本图像处理方法文档格式.docx
《Delphi基本图像处理方法文档格式.docx》由会员分享,可在线阅读,更多相关《Delphi基本图像处理方法文档格式.docx(16页珍藏版)》请在冰点文库上搜索。
0thenSrcRGB1:
=SrcBmp.ScanLine[i-1]elseSrcRGB1:
=SrcRGB;
Inc(SrcRGB1;
SrcRGB2:
Inc(SrcRGB2;
endelseif(AzimuthChange>
=-135and(AzimuthChange<
-90thenbeginifi>
=SrcRGB1;
=-90and(AzimuthChange<
-45thenbeginifi>
=-45and(AzimuthChange<
0thenbeginSrcRGB1:
ifi>
0thenSrcRGB2:
=SrcBmp.ScanLine[i-1]elseSrcRGB2:
=0and(AzimuthChange<
45thenbeginSrcRGB2:
if(i<
SrcBmp.Height-1thenSrcRGB1:
=SrcBmp.ScanLine[i+1]elseSrcRGB1:
=45and(AzimuthChange<
90thenbeginif(i<
=90and(AzimuthChange<
135thenbeginif(i<
=135and(AzimuthChange<
=180thenbeginif(i<
SrcBmp.Height-1thenSrcRGB2:
=SrcBmp.ScanLine[i+1]elseSrcRGB2:
SrcRGB1:
end;
forj:
=0toSrcBmp.Width-1dobeginif(AzimuthChange>
-135thenbeginAzimuthvalue:
=AzimuthChange+180;
R:
=SrcRGB.rgbtRed-((SrcRGB1.rgbtRed*Azimuthvaluediv45-((SrcRGB2.rgbtRed*(45-Azimuthvaluediv45+78;
G:
=SrcRGB.rgbtGreen-((SrcRGB1.rgbtGreen*Azimuthvaluediv45-((SrcRGB2.rgbtGreen*(45-Azimuthvaluediv45+78;
B:
=SrcRGB.rgbtBlue-((SrcRGB1.rgbtBlue*Azimuthvaluediv45-((SrcRGB2.rgbtBlue*(45-Azimuthvaluediv45+78;
-90thenbeginAzimuthvalue:
=AzimuthChange+135;
=SrcR
GB.rgbtBlue-((SrcRGB1.rgbtBlue*Azimuthvaluediv45-((SrcRGB2.rgbtBlue*(45-Azimuthvaluediv45+78;
-45thenbeginifj=1thenInc(SrcRGB1,-1;
Azimuthvalue:
=AzimuthChange+90;
0thenbeginifj=1thenbeginInc(SrcRGB1,-1;
Inc(SrcRGB2,-1;
=AzimuthChange+45;
45thenbeginifj=1thenbeginInc(SrcRGB1,-1;
=AzimuthChange;
90thenbeginifj=1thenInc(SrcRGB2,-1;
=AzimuthChange-45;
135thenbeginAzimuthvalue:
=AzimuthChange-90;
=180thenbeginAzimuthvalue:
=AzimuthChange-135;
=SrcRGB.rgbtGreen-((SrcRGB1.rgbtGreen*Azimuthvaluediv45-((SrcRGB2.rgbtGree
n*(45-Azimuthvaluediv45+78;
=Min(R,255;
=Max(R,0;
=Min(G,255;
=Max(G,0;
=Min(B,255;
=Max(B,0;
Gray:
=(Rshr2+(Rshr4+(Gshr1+(Gshr4+(Bshr3;
DestRGB.rgbtRed:
=Gray;
DestRGB.rgbtGreen:
DestRGB.rgbtBlue:
if(j=-180and(AzimuthChange<
-135or((AzimuthChange>
=90and(AzimuthChange<
=180thenbeginInc(SrcRGB1;
if(j=135and(AzimuthChange<
180or((AzimuthChange>
=-180and(AzimuthChange<
=-90thenbeginInc(SrcRGB2;
Inc(SrcRGB;
Inc(DestRGB;
procedureEmboss(Bmp:
ElevationChange:
WeightChange:
varDestBmp:
begin DestBmp:
=TBitmap.Create;
DestBmp.Assign(Bmp;
Emboss(Bmp,DestBmp,AzimuthChange,ElevationChange,WeightChange;
Bmp.Assign(DestBmp;
//反色procedureNegative(Bmp:
vari,j:
Integer;
PRGB:
beginBmp.PixelFormat:
=pf24Bit;
fori:
=0toBmp.Height-1dobeginPRGB:
=Bmp.ScanLine[i];
=0toBmp.Width-1dobeginPRGB^.rgbtRed:
=notPRGB^.rgbtRed;
PRGB^.rgbtGreen:
=notPRGB^.rgbtGreen;
PRGB^.rgbtBlue:
=notPRGB^.rgbtBlue;
Inc(PRGB;
//曝光procedureExposure(Bmp:
=0toBmp.Width-1dobeginifPRGB^.rgbtRed<
128thenPRGB^.rgbtRed:
ifPRGB^.rgbtGreen<
128thenPRGB^.rgbtGreen:
ifPRGB^.rgbtBlue<
128thenPRGB^.rgbtBlue:
//模糊procedureBlur(SrcBmp:
Integer;
SrcRGB:
pRGBTriple;
SrcNextRGB:
SrcPreRGB:
Value:
procedureIncRGB;
beginInc(SrcPreRGB;
Inc(SrcNextRGB;
procedureDecRGB;
beginInc(SrcPreRGB,-1;
Inc(SrcRGB,-1;
Inc(SrcNextRGB,-1;
beginSrcBmp.PixelFormat:
=0toSrcBmp.Height-1dobeginifi>
0thenSrcPreRGB:
=SrcBmp.ScanLine[i-1]elseSrcPreRGB:
SrcRGB:
ifi<
SrcBmp.Height-1thenSrcNextRGB:
=SrcBmp.ScanLine[i+1]elseSrcNextRGB:
=SrcBmp.ScanLine[i];
=0toSrcBmp.Width-1dobeginifj>
0thenDecRGB;
=SrcPreRGB.rgbtRed+SrcRGB.rgbtRed+SrcNextRGB.rgbtRed;
ifj>
0thenIncRGB;
=Value+SrcPreRGB.rgbtRed+SrcRGB.rgbtRed+SrcNextRGB.rgbtRed;
ifj<
SrcBmp.Width-1thenIncRGB;
=(Value+SrcPreRGB.rgbtRed+SrcRGB.rgbtRed+SrcNextRGB.rgbtReddiv9;
DecRGB;
SrcRGB.rgbtRed:
=value;
ifj>
=SrcPreRGB.rgbtGreen+SrcRGB.rgbtGreen+SrcNextRGB.rgbtGreen;
=Value+SrcPreRGB.rgbtGreen+SrcRGB.rgbtGreen+SrcNextRGB.rgbtGreen;
=(Value+SrcPreRGB.rgbtGreen+SrcRGB.rgbtGreen+SrcNextRGB.rgbtGreendiv9;
SrcRGB.rgbtGreen:
=SrcPreRGB.rgbtBlue+SrcRGB.rgbtBlue+SrcNextRGB.rgbtBlue;
=Value+SrcPreRGB.rgbtBlue+SrcRGB.rgbtBlue+SrcNextRGB.rgbtBlue;
=(Value+SrcPreRGB.rgbtBlue+SrcRGB.rgbtBlue+SrcNextRGB.rgbtBluediv9;
SrcRGB.rgbtBlue:
IncRGB;
//锐化procedureSharpen(SrcBmp:
=SrcBmp.ScanLine[i-1]elseSrcPreRGB:
=0toSrcBmp.Width-1dobeginifj=1thenDec(SrcPreRGB;
=SrcRGB.rgbtRed+(SrcRGB.rgbtRed-SrcPreRGB.rgbtReddiv2;
=Max(0,Value;
=Min(255,Value;
=SrcRGB.rgbtGreen+(SrcRGB.rgbtGreen-SrcPreRGB.rgbtGreendiv2;
=SrcRGB.rgbtBlue+(SrcRGB.rgbtBlue-SrcPreRGB.rgbtBluediv2;
Inc(SrcPreRGB;
[图像的旋转和翻转]以下代码用ScanLine配合指针移动实现,用于24位色!
//旋转90度procedureRotate90(constBitmap:
vari,j:
rowIn,rowOut:
Bmp:
Width,Height:
beginBmp:
Bmp.Width:
=Bitmap.Height;
Bmp.Height:
=Bitmap.Width;
Bmp.PixelFormat:
=pf24bit;
Width:
=Bitmap.Width-1;
Height:
=Bitmap.Height-1;
=0toHeightdobeginrowIn:
=Bitmap.ScanLine[j];
=0toWidthdobeginrowOut:
Inc(rowOut,Height-j;
rowOut^:
=rowIn^;
Inc(rowIn;
Bitmap.Assign(Bmp;
//旋转180度procedureRotate180(constBitmap:
Bmp.Pixe