Data update

This commit is contained in:
Ingy döt Net 2026-02-01 16:33:20 -08:00
parent 5150844a7d
commit 4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions

View file

@ -1,35 +0,0 @@
type Float_Luminance is new Float;
type Float_Pixel is record
R, G, B : Float_Luminance := 0.0;
end record;
function "*" (Left : Float_Pixel; Right : Float_Luminance) return Float_Pixel is
pragma Inline ("*");
begin
return (Left.R * Right, Left.G * Right, Left.B * Right);
end "*";
function "+" (Left, Right : Float_Pixel) return Float_Pixel is
pragma Inline ("+");
begin
return (Left.R + Right.R, Left.G + Right.G, Left.B + Right.B);
end "+";
function To_Luminance (X : Float_Luminance) return Luminance is
pragma Inline (To_Luminance);
begin
if X <= 0.0 then
return 0;
elsif X >= 255.0 then
return 255;
else
return Luminance (X);
end if;
end To_Luminance;
function To_Pixel (X : Float_Pixel) return Pixel is
pragma Inline (To_Pixel);
begin
return (To_Luminance (X.R), To_Luminance (X.G), To_Luminance (X.B));
end To_Pixel;

View file

@ -1,46 +0,0 @@
type Kernel_3x3 is array (-1..1, -1..1) of Float_Luminance;
procedure Filter (Picture : in out Image; K : Kernel_3x3) is
function Get (I, J : Integer) return Float_Pixel is
pragma Inline (Get);
begin
if I in Picture'Range (1) and then J in Picture'Range (2) then
declare
Color : Pixel := Picture (I, J);
begin
return (Float_Luminance (Color.R), Float_Luminance (Color.G), Float_Luminance (Color.B));
end;
else
return (others => 0.0);
end if;
end Get;
W11, W12, W13 : Float_Pixel; -- The image window
W21, W22, W23 : Float_Pixel;
W31, W32, W33 : Float_Pixel;
Above : array (Picture'First (2) - 1..Picture'Last (2) + 1) of Float_Pixel;
This : Float_Pixel;
begin
for I in Picture'Range (1) loop
W11 := Above (Picture'First (2) - 1); -- The upper row is taken from the cache
W12 := Above (Picture'First (2) );
W13 := Above (Picture'First (2) + 1);
W21 := (others => 0.0); -- The middle row
W22 := Get (I, Picture'First (2) );
W23 := Get (I, Picture'First (2) + 1);
W31 := (others => 0.0); -- The bottom row
W32 := Get (I+1, Picture'First (2) );
W33 := Get (I+1, Picture'First (2) + 1);
for J in Picture'Range (2) loop
This :=
W11 * K (-1, -1) + W12 * K (-1, 0) + W13 * K (-1, 1) +
W21 * K ( 0, -1) + W22 * K ( 0, 0) + W23 * K ( 0, 1) +
W31 * K ( 1, -1) + W32 * K ( 1, 0) + W33 * K ( 1, 1);
Above (J-1) := W21;
W11 := W12; W12 := W13; W13 := Above (J+1); -- Shift the window
W21 := W22; W22 := W23; W23 := Get (I, J+1);
W31 := W32; W32 := W23; W33 := Get (I+1, J+1);
Picture (I, J) := To_Pixel (This);
end loop;
Above (Picture'Last (2)) := W21;
end loop;
end Filter;

View file

@ -1,12 +0,0 @@
F1, F2 : File_Type;
begin
Open (F1, In_File, "city.ppm");
declare
X : Image := Get_PPM (F1);
begin
Close (F1);
Create (F2, Out_File, "city_sharpen.ppm");
Filter (X, ((-1.0, -1.0, -1.0), (-1.0, 9.0, -1.0), (-1.0, -1.0, -1.0)));
Put_PPM (F2, X);
end;
Close (F2);