Image Delphi algorithm foil (median, mean, Gaussian)

//排序 paixu  
procedure paixu(var temp : array of Byte);  
var  
   i,j : Integer;  
   t : Byte;  
begin  
   for i := low(temp) to high(temp) do  
    for j := i to high(temp) do  
     if temp[i]<temp[j] then  
     begin  
       t := temp[i];  
       temp[i] := temp[j];  
       temp[j] := t;  
     end;  
end;  
//灰度图的中值滤波 3x3  
procedure zhongzhi(b : TBitmap);  
var  
   b_read : TBitmap;  
   x, y : Integer;  
   wdata , rdata : TBitmapData ;  
   p: PByteArray;  
   p1 , p2 , p3 : PByteArray;  
   temp : array [0..8] of Byte;  
begin  
   b_read := TBitmap.Create;  
   b_read.Assign(b);  
   //一个用来修改  w一个用来读取 r  
   if  b.Map( TMapAccess.Write,wdata) and b_read.Map( TMapAccess.Read,rdata) then  
   begin  
        for y := 1 to rdata.Height - 2 do  
        begin  
            p := wdata.GetScanline(y);  
            p1 := rdata.GetScanline(y-1);  
            p2 := rdata.GetScanline(y);  
            p3 := rdata.GetScanline(y+1);  
     

Guess you like

Origin blog.csdn.net/zxm8513/article/details/104727348