Code clean
This commit is contained in:
parent
52c87bea36
commit
f3c4ba7b0e
28
Makefile
28
Makefile
@ -1,30 +1,19 @@
|
|||||||
#On purge la liste des suffixes utilis<69> pour les r<>les implicites
|
|
||||||
.SUFFIXES:
|
.SUFFIXES:
|
||||||
|
|
||||||
#On ajoute simplements les extensions dont l'on a besoin
|
|
||||||
.SUFFIXES:.cpp .o
|
.SUFFIXES:.cpp .o
|
||||||
|
|
||||||
#Nom de l'executable
|
EXEC=emd
|
||||||
EXEC=tp1
|
|
||||||
|
|
||||||
#Liste des fichiers sources separes par des espaces
|
|
||||||
SOURCES=main.cpp
|
SOURCES=main.cpp
|
||||||
|
|
||||||
#Liste des fichiers objets
|
|
||||||
OBJETS=$(SOURCES:%.cpp=%.o)
|
OBJETS=$(SOURCES:%.cpp=%.o)
|
||||||
|
|
||||||
#Compilateur et options de compilation
|
CC=g++
|
||||||
CCPP=g++
|
|
||||||
CFLAGS=-Wall -ansi -pedantic -ffast-math -I /usr/X11R6/include -I ./CImg
|
CFLAGS=-Wall -ansi -pedantic -ffast-math -I /usr/X11R6/include -I ./CImg
|
||||||
|
|
||||||
|
|
||||||
LFLAGS= -L . -L /usr/X11R6/lib -lpthread -lX11 -lXext -Dcimg_use_xshm -lm
|
LFLAGS= -L . -L /usr/X11R6/lib -lpthread -lX11 -lXext -Dcimg_use_xshm -lm
|
||||||
|
|
||||||
#R<>le explicite de construction de l'ex<65>utable
|
|
||||||
$(EXEC):$(OBJETS) Makefile
|
$(EXEC):$(OBJETS) Makefile
|
||||||
$(CCPP) -o $(EXEC) $(OBJETS) $(LFLAGS)
|
$(CC) -o $(EXEC) $(OBJETS) $(LFLAGS)
|
||||||
.cpp.o:
|
.cpp.o:
|
||||||
$(CCPP) $(CFLAGS) -c $< -o $@
|
$(CC) $(CFLAGS) -c $< -o $@
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm $(OBJETS)
|
rm $(OBJETS)
|
||||||
@ -33,13 +22,8 @@ clear:
|
|||||||
depend:
|
depend:
|
||||||
sed -e "/^#DEPENDANCIES/,$$ d" Makefile >dependances
|
sed -e "/^#DEPENDANCIES/,$$ d" Makefile >dependances
|
||||||
echo "#DEPENDANCIES" >> dependances
|
echo "#DEPENDANCIES" >> dependances
|
||||||
$(CCPP) -MM $(SOURCES) >> dependances
|
$(CC) -MM $(SOURCES) >> dependances
|
||||||
cat dependances >Makefile
|
cat dependances >Makefile
|
||||||
rm dependances
|
rm dependances
|
||||||
|
|
||||||
#DEPENDANCIES
|
main.o: main.cpp
|
||||||
main.o: main.cpp
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
81
main.cpp
81
main.cpp
@ -1,5 +1,5 @@
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// DM : Empirical Mode Decomposition //
|
// Empirical Mode Decomposition //
|
||||||
// BERNARD Guillaume //
|
// BERNARD Guillaume //
|
||||||
// DURAND William //
|
// DURAND William //
|
||||||
// ZZ3F2 ISIMA //
|
// ZZ3F2 ISIMA //
|
||||||
@ -11,95 +11,82 @@
|
|||||||
using namespace cimg_library;
|
using namespace cimg_library;
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
|
Main
|
||||||
Main
|
*******************************************************************************/
|
||||||
|
|
||||||
*******************************************************************************/
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
// Ouverture de l'image
|
|
||||||
CImg<unsigned char> imgLena("lena.bmp");
|
CImg<unsigned char> imgLena("lena.bmp");
|
||||||
|
|
||||||
// Affichage de l'image de base
|
|
||||||
CImgDisplay dispBase(imgLena,"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> imgMax = imgLena;
|
||||||
CImg<unsigned char> imgMin = imgLena;
|
CImg<unsigned char> imgMin = imgLena;
|
||||||
|
|
||||||
// Parcours de l'image
|
|
||||||
for (int i = 0; i<imgLena.width() ; i+=3) {
|
for (int i = 0; i<imgLena.width() ; i+=3) {
|
||||||
for (int j = 0; j<imgLena.height() ; j+=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 xmax = i;
|
||||||
int ymax = j;
|
int ymax = j;
|
||||||
int xmin = i;
|
int xmin = i;
|
||||||
int ymin = j;
|
int ymin = j;
|
||||||
|
|
||||||
// Sauvegarde des valeurs
|
// save values
|
||||||
unsigned char max = imgMax(i,j);
|
unsigned char max = imgMax(i,j);
|
||||||
unsigned char min = imgMin(i,j);
|
unsigned char min = imgMin(i,j);
|
||||||
|
|
||||||
// Parcours en 3x3
|
// 3x3
|
||||||
for (int k = i; k<i+3 ; k++) {
|
for (int k = i; k<i+3 ; k++) {
|
||||||
for (int l = j; l<j+3 ; l++) {
|
for (int l = j; l<j+3 ; l++) {
|
||||||
|
|
||||||
// Recherche du max
|
// Max?
|
||||||
if ((imgMax(k,l) <= max)&&(l!=ymax &&k!=xmax)) {
|
if ((imgMax(k,l) <= max)&&(l!=ymax &&k!=xmax)) {
|
||||||
imgMax(k,l) = 0;
|
imgMax(k,l) = 0;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
max = imgMax(k,l);
|
max = imgMax(k,l);
|
||||||
imgMax(xmax,ymax) = 0;
|
imgMax(xmax,ymax) = 0;
|
||||||
xmax = k;
|
xmax = k;
|
||||||
ymax = l;
|
ymax = l;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Recherche du min
|
// Min?
|
||||||
if ((imgMin(k,l) >= min)&&(l!=ymin &&k!=xmin)) {
|
if ((imgMin(k,l) >= min)&&(l!=ymin &&k!=xmin)) {
|
||||||
imgMin(k,l) = 0;
|
imgMin(k,l) = 0;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
min = imgMin(k,l);
|
min = imgMin(k,l);
|
||||||
imgMin(xmin,ymin) = 0;
|
imgMin(xmin,ymin) = 0;
|
||||||
xmin = k;
|
xmin = k;
|
||||||
ymin = l;
|
ymin = l;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Affichage de l'image de max et min
|
// Display images for max and min
|
||||||
CImgDisplay dispMax(imgMax,"Image de Max");
|
CImgDisplay dispMax(imgMax,"Image de Max");
|
||||||
CImgDisplay dispMin(imgMin,"Image de Min");
|
CImgDisplay dispMin(imgMin,"Image de Min");
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// Partie 2: Moyenne //
|
// Part 2: Average //
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
CImg<unsigned char> imgMoyenne = (imgMax+imgMin)/2;
|
CImg<unsigned char> imgMoyenne = (imgMax+imgMin)/2;
|
||||||
|
|
||||||
CImgDisplay dispMoyenne(imgMoyenne,"Image Moyenne");
|
CImgDisplay dispMoyenne(imgMoyenne,"Image Moyenne");
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// Partie 3: Suppression //
|
// Partie 3: Deletion //
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
CImg<unsigned char> imgFin = imgLena - imgMoyenne;
|
CImg<unsigned char> imgFin = imgLena - imgMoyenne;
|
||||||
|
|
||||||
CImgDisplay dispFin(imgFin,"Image Finale");
|
CImgDisplay dispFin(imgFin,"Image Finale");
|
||||||
|
|
||||||
while (!dispBase.is_closed())
|
while (!dispBase.is_closed()) {
|
||||||
{
|
|
||||||
dispBase.wait();
|
dispBase.wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user