unit filterWaves;
(* ***** BEGIN LICENSE BLOCK *****
* Copyright (C) 2004 Durand Emmanuel
* Copyright (C) 2004 Burgel Eric
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Contact :
* filters@edurand.com
* filters@burgel.com
*
* ***** END LICENSE BLOCK ***** *)
{
eburgel (filters@burgel.com)
}
interface
uses
filter, fparameters, image, LacModel ;
type
TFilterWaves = class(TFilter)
public
constructor Create; override;
procedure setParameterImage(const aName: String; const aImage: PBitmap32); override ;
procedure Run(); override;
private
parameterImageIn, parameterImageOut : TParameterImage;
width, height : Integer ;
lac : TLac ;
procedure _run();
end;
implementation
uses
imageIO, Math ;
constructor TFilterWaves.Create;
begin
inherited;
parameterImageIn:=addParameterImage('inImage', 'input image to invert');
parameterImageOut:=addParameterImage('outImage', 'result image of invertion');
lac := nil ;
end;
procedure TFilterWaves.setParameterImage(const aName: String; const aImage: PBitmap32) ;
Var
x, y : Integer ;
pSrc : PColor32Array;
Begin
inherited ;
if aName = 'inImage' Then Begin
width := aImage.Width ;
height := aImage.Height ;
lac.Free ;
lac := TLac.create(width, height);
for y := height-1 downto 0 do Begin
pSrc := scanLine(aImage, y) ;
for x := width-1 downto 0 do Begin
lac.setPoint(x, y, Intensity(pSrc^[x])div 2);
End ;
End ;
//lac.setPoint(width div 2, height div 2, 64) ;
End ;
End ;
procedure TFilterWaves.Run();
begin
if (parameterImageIn.Image<>nil) and (parameterImageOut.Image<>nil) then begin
_run();
end;
end;
procedure TFilterWaves._run();
var
PDest : PColor32Array;
x, y, maxX, maxY : Integer ;
imgOut : PBitmap32 ;
value : Single ;
begin
imgOut := parameterImageOut.Image ;
maxX := scanWidth(imgOut)-1 ;
maxY := scanHeight(imgOut)-1 ;
// Compute a single step
lac.compute() ;
for y:=0 to maxY do begin
pDest := scanLine(imgOut, y) ;
for x := 0 To maxX do Begin
value := lac.getPoint(x, y) ;
pDest^[0] := Gray32(floor(value)+128) ;
inc(pDest) ;
End ;
end ;
end;
end.