Code clean

This commit is contained in:
William DURAND
2011-11-30 12:24:28 +01:00
parent 52c87bea36
commit f3c4ba7b0e
2 changed files with 40 additions and 69 deletions

View File

@@ -1,5 +1,5 @@
////////////////////////////////////////////////////////////////////////////////
// DM : Empirical Mode Decomposition //
// Empirical Mode Decomposition //
// BERNARD Guillaume //
// DURAND William //
// ZZ3F2 ISIMA //
@@ -11,95 +11,82 @@
using namespace cimg_library;
/*******************************************************************************
Main
*******************************************************************************/
Main
*******************************************************************************/
int main()
{
// Ouverture de l'image
CImg<unsigned char> imgLena("lena.bmp");
// Affichage de l'image de base
CImgDisplay dispBase(imgLena,"Image de base");
///////////////////////////////////////////////////////////////////////////////
// Partie 1: Cherche les extremums //
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Part 1: Finding minimas and maximas //
///////////////////////////////////////////////////////////////////////////////
CImg<unsigned char> imgMax = imgLena;
CImg<unsigned char> imgMin = imgLena;
// Parcours de l'image
for (int i = 0; i<imgLena.width() ; i+=3) {
for (int j = 0; j<imgLena.height() ; j+=3) {
// Sauvegarde de la place du max et du min
// Save max and min locations
int xmax = i;
int ymax = j;
int xmin = i;
int ymin = j;
// Sauvegarde des valeurs
// save values
unsigned char max = imgMax(i,j);
unsigned char min = imgMin(i,j);
// Parcours en 3x3
// 3x3
for (int k = i; k<i+3 ; k++) {
for (int l = j; l<j+3 ; l++) {
// Recherche du max
// Max?
if ((imgMax(k,l) <= max)&&(l!=ymax &&k!=xmax)) {
imgMax(k,l) = 0;
}
else
{
} else {
max = imgMax(k,l);
imgMax(xmax,ymax) = 0;
xmax = k;
ymax = l;
}
// Recherche du min
// Min?
if ((imgMin(k,l) >= min)&&(l!=ymin &&k!=xmin)) {
imgMin(k,l) = 0;
}
else
{
} else {
min = imgMin(k,l);
imgMin(xmin,ymin) = 0;
xmin = k;
ymin = l;
}
}
}
}
}
// Affichage de l'image de max et min
// Display images for max and min
CImgDisplay dispMax(imgMax,"Image de Max");
CImgDisplay dispMin(imgMin,"Image de Min");
///////////////////////////////////////////////////////////////////////////////
// Partie 2: Moyenne //
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Part 2: Average //
///////////////////////////////////////////////////////////////////////////////
CImg<unsigned char> imgMoyenne = (imgMax+imgMin)/2;
CImgDisplay dispMoyenne(imgMoyenne,"Image Moyenne");
///////////////////////////////////////////////////////////////////////////////
// Partie 3: Suppression //
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Partie 3: Deletion //
///////////////////////////////////////////////////////////////////////////////
CImg<unsigned char> imgFin = imgLena - imgMoyenne;
CImgDisplay dispFin(imgFin,"Image Finale");
while (!dispBase.is_closed())
{
while (!dispBase.is_closed()) {
dispBase.wait();
}
return 0;
}