Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function TFloatMatrix.Normalize(Alpha:Single=0.0; Beta:Single=1.0): TFloatMatrix;
- var
- Lo,Hi,oldRange,newRange:Single;
- X,Y,W,H: Int32;
- begin
- H := High(Self);
- W := High(Self[0]);
- SetLength(Result, H+1,W+1);
- Self.MinMax(Lo,Hi); //returns the smallest and largest values
- oldRange := Hi-Lo;
- newRange := Beta-Alpha;
- for Y:=0 to H do
- for X:=0 to W do
- Result[Y,X] := (Self[Y,X] - lo) / oldRange * newRange + Alpha;
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement