1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
| ***************Extraction des Hards Cuts****************/
/************
Cette classe extrait les HC par la méthode de TDV et par l'amélioration
en entrée on doit spécifier le w (taille de la fenêtre) alpha (le coefficient utilisé)
et on doit entrer l'histogramme de variance de luminance
*************/
import java.io.*;
import java.util.*;
import java.math.*;
class HardsCutsa
{ int debut;
int nbreHardscuts;
int [] histogramme;
int w;
double alpha;
//Constructeur de la classe
HardsCutsa(int w1,double alpha1,int [] histogramme1,int debut1)
{
debut=debut1;
w=w1;
histogramme=histogramme1;
alpha=alpha1;
}
//Extraction des HC par la méthode TDV
public int[][] ExtraireHC()
{
int [] IndiceImageVHC=new int[histogramme.length];
int [] ImageHC=new int[histogramme.length];
int k=2*w;
int nbrefenetres=(int)(histogramme.length/k);
int nbreHardscuts=0;
int [] tabHC =new int[histogramme.length];
int [][] tabHC1;
int i=0;
int indicefenetre=0;
if(nbrefenetres!=0) indicefenetre=1;
while ((i+k<histogramme.length)& (indicefenetre<=nbrefenetres))
{
int Somme=0;
int max=Recherchermax(histogramme,i,i+k);
int indicemax=RechercherIndice(histogramme,i,i+k,max);
for(int j=i;j<i+2*w;j++)
{
if (j!=indicemax) Somme=Somme+histogramme[j];
}
double seuil =alpha*Somme/k; // le seuil
if (max>=seuil)
{
tabHC[nbreHardscuts]=max;
ImageHC[nbreHardscuts]=indicemax;
nbreHardscuts++;
}
i=i+k+1;
indicefenetre++;
} |
Partager