text stringlengths 0 234 |
|---|
Function Body: equalimg : imge; |
cumsum : array (1..256) of float; |
begin |
-- calculate the cumulative sum of the histogram values |
for i in 1..256 loop |
if i = 1 then |
cumsum(i) := float(hist.count(i)); |
else |
cumsum(i) := cumsum(i-1) + float(hist.count(i)); |
end if; |
end loop; |
-- normalize the cumulative sum by dividing by the total number of pixels |
-- then multiply by the maximum grayscale value (i.e., 255) |
for i in 1..256 loop |
cumsum(i) := 255.0 * cumsum(i) / (float(img.dx) * float(img.dy)); |
end loop; |
-- map the original values to the results of the array above to calculate histogram equalization |
for i in 1..img.dx loop |
for j in 1..img.dy loop |
equalimg.pixel(i,j) := integer(cumsum(img.pixel(i,j))); |
end loop; |
end loop; |
return equalimg; |
Function Definition: procedure Main is |
Function Body: pragma Suppress(All_Checks); |
Matrix_Size : constant := 3200; |
type Matrix_Range is range 0 .. Matrix_Size - 1; |
Bound_High, Bound_Low : Matrix_Range; |
type Pile is range 0..7 with Size=>8; |
type Pile_Pointer is access all Pile; |
type Generic_Matrix_Row is array (Matrix_Range range <>) of aliased Pile with Pack; |
subtype Matrix_Row is Generic_Matrix_Row(Matrix_Range); |
subtype Matrix_Sub_Row is Generic_Matrix_Row(0..7); |
type Matrix is array (Matrix_Range) of Matrix_Row with Pack; |
type Matrix_Pointer is access all Matrix; |
type m128i is array (0 .. 15) of Pile with Pack, Alignment=>16; |
pragma Machine_Attribute (m128i, "vector_type"); |
pragma Machine_Attribute (m128i, "may_alias"); |
---------------------------------------------------------------------- |
function ia32_Add (X, Y : m128i) return m128i with Inline; |
pragma Import (Intrinsic, ia32_Add, "__builtin_ia32_paddb128"); |
function ia32_Load (X : Pile_Pointer) return m128i with Inline; |
pragma Import (Intrinsic, ia32_Load, "__builtin_ia32_loaddqu"); |
procedure ia32_Store (X : Pile_Pointer; Y : m128i) with Inline; |
pragma Import (Intrinsic, ia32_Store, "__builtin_ia32_storedqu"); |
procedure Print (Map : in Matrix; Name : in String) is |
begin |
Put_Line(Name); |
for I in Bound_Low .. Bound_High loop |
for J in Bound_Low .. Bound_High loop |
Put(Pile'Image(Map(I)(J))); |
end loop; |
New_Line(1); |
end loop; |
Put_Line("------------"); |
Function Definition: function Move is new Ada.Unchecked_Conversion (Source=>Mod_64, Target=>Matrix_Sub_Row); |
Function Body: function Move is new Ada.Unchecked_Conversion (Source=>Matrix_Sub_Row, Target=>Mod_64); |
Changed : Boolean := False; |
Local_Bound_High : constant Matrix_Range := Bound_High; |
Local_Bound_Low : constant Matrix_Range := Bound_Low; |
I : Matrix_Range := Bound_Low; |
Temp_Values : Mod_64_Array; |
begin |
while I <= Local_Bound_High loop |
declare |
J : Matrix_Range := Local_Bound_Low - (Local_Bound_Low mod 16); |
Temp : m128i; |
Sum_m128i_Buffer : m128i; |
Upper_Sum_m128i_Buffer : m128i; |
Lower_Sum_m128i_Buffer : m128i; |
begin |
while J <= Local_Bound_High loop |
Temp_Values(0) := (Move(Base(I)(J..J+7)) / 2**2) AND 16#0F0F0F0F0F0F0F0F#; |
Temp_Values(1) := (Move(Base(I)(J+8..J+15)) / 2**2) AND 16#0F0F0F0F0F0F0F0F#; |
if (Temp_Values(0) OR Temp_Values(1)) /= 0 then |
Changed := True; |
if I - 1 < Bound_Low then |
Bound_Low := Bound_Low - 1; |
Bound_High := Bound_High + 1; |
end if; |
Temp := ia32_Load(Temp_Values(0)'Access); |
Upper_Sum_m128i_Buffer := ia32_Load(Base(I-1)(J)'Access); |
ia32_Store(Base(I-1)(J)'Access, ia32_Add(Upper_Sum_m128i_Buffer, Temp)); |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.