Forum ada95000 Dernière connexion : 18/06/2025 à 03:26
Fin de session : 18/06/2025 à 03:36

Vous n'êtes pas connecté [Connexion - Inscription]
Go Bottom
Version imprimable | Envoyer à un ami | S'abonner | Ajouter aux Favoris Nouveau SujetNouveau sondageRépondre
Auteur: Sujet: Elargir le spectre d'une image .pgm   ( Réponses: 0 | Vues: 586 )
ftbass
Administrator
StaffStaffStaffStaffStaffStaffStaffStaffStaff
 
images/avatars/WC3HumanOp1.gif
 
Messages: 72
Inscrit(e) le: 27/02/2004
Déconnecté(e)
Publié le 11/07/2004 à 02:48 Reply With Quote
Elargir le spectre d'une image .pgm

code:

function GetIntensiteMax(Matrice : in TypeMatrice) return integer is

Resultat : integer := 0;
i, j : integer := 0;

begin
while (i <= Matrice'Last(1)) and (j <= Matrice'Last(2)) and (Resultat /= 255) loop
if character'pos(Matrice(i, j)) > Resultat then
Resultat := character'pos(Matrice(i, j));
end if;
if j = 255 and i < 255 then
j := 0;
i := i + 1;
else
j := j + 1;
end if;
end loop;

return Resultat;


end GetIntensiteMax;

-- Fonction qui retourne l'intensité min des pixels d'une image
function GetIntensiteMin(Matrice : in TypeMatrice) return integer is

Resultat : integer := 255;
i, j : integer := 0;

begin
while (i <= Matrice'Last(1)) and (j <= Matrice'Last(2)) and (Resultat /= 0) loop
if character'pos(Matrice(i, j)) < Resultat then
Resultat := character'pos(Matrice(i, j));
end if;
if j = 255 and i < 255 then
j := 0;
i := i + 1;
else
j := j + 1;
end if;
end loop;

return Resultat;

end GetIntensiteMin;



-- Fonction qui étend le spectre à 0..255
function ElargirSpectre(MatriceI : in typeMatrice) return TypeMatrice is

Resultat : TypeMatrice(MatriceI'range(1), MatriceI'range(2));

Max, Min : Integer;
Coeff : Float;

begin
  -- Détermination du max de l'image originale
  Max := GetIntensiteMax(MatriceI);
  -- Détermination de son min
  Min := GetIntensiteMin(MatriceI);
  -- Détemination du Coeff
  Coeff := 255.0 / (Float(Max) - Float(Min));
  for i in MatriceI'range(1) loop
     for j in MatriceI'range(2) loop
        Resultat(i, j) := character'val(Integer((Float(character'pos(MatriceI(i, j))) - Float(Min)) * Coeff));
     end loop;
  end loop;
 
  return Resultat;
 
end ElargirSpectre;
Go Top #73 Go Bottom
View ftbass's ProfileE-Mail ftbassVisit ftbass's HomepageView All Posts by ftbassU2U Member
Nouveau SujetNouveau sondageRépondre

Go Top
10.3.122.74 03:26 - 18 Juin 2025 10.3.122.74
[ 0.2593760 secondes | Effacer le cookie | 18 requêtes ]
Oxygen v1.0.11 © 2002  |  Oxygen WebSite © 2002