Added first workaround
This commit is contained in:
parent
b5c571e2d2
commit
52c87bea36
45
Makefile
Normal file
45
Makefile
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
#On purge la liste des suffixes utilis<69> pour les r<>les implicites
|
||||||
|
.SUFFIXES:
|
||||||
|
|
||||||
|
#On ajoute simplements les extensions dont l'on a besoin
|
||||||
|
.SUFFIXES:.cpp .o
|
||||||
|
|
||||||
|
#Nom de l'executable
|
||||||
|
EXEC=tp1
|
||||||
|
|
||||||
|
#Liste des fichiers sources separes par des espaces
|
||||||
|
SOURCES=main.cpp
|
||||||
|
|
||||||
|
#Liste des fichiers objets
|
||||||
|
OBJETS=$(SOURCES:%.cpp=%.o)
|
||||||
|
|
||||||
|
#Compilateur et options de compilation
|
||||||
|
CCPP=g++
|
||||||
|
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
|
||||||
|
|
||||||
|
#R<>le explicite de construction de l'ex<65>utable
|
||||||
|
$(EXEC):$(OBJETS) Makefile
|
||||||
|
$(CCPP) -o $(EXEC) $(OBJETS) $(LFLAGS)
|
||||||
|
.cpp.o:
|
||||||
|
$(CCPP) $(CFLAGS) -c $< -o $@
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm $(OBJETS)
|
||||||
|
clear:
|
||||||
|
rm $(EXEC)
|
||||||
|
depend:
|
||||||
|
sed -e "/^#DEPENDANCIES/,$$ d" Makefile >dependances
|
||||||
|
echo "#DEPENDANCIES" >> dependances
|
||||||
|
$(CCPP) -MM $(SOURCES) >> dependances
|
||||||
|
cat dependances >Makefile
|
||||||
|
rm dependances
|
||||||
|
|
||||||
|
#DEPENDANCIES
|
||||||
|
main.o: main.cpp
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
105
main.cpp
Normal file
105
main.cpp
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// DM : Empirical Mode Decomposition //
|
||||||
|
// BERNARD Guillaume //
|
||||||
|
// DURAND William //
|
||||||
|
// ZZ3F2 ISIMA //
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "CImg.h"
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
using namespace cimg_library;
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
|
||||||
|
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 //
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
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
|
||||||
|
int xmax = i;
|
||||||
|
int ymax = j;
|
||||||
|
int xmin = i;
|
||||||
|
int ymin = j;
|
||||||
|
|
||||||
|
// Sauvegarde des valeurs
|
||||||
|
unsigned char max = imgMax(i,j);
|
||||||
|
unsigned char min = imgMin(i,j);
|
||||||
|
|
||||||
|
// Parcours en 3x3
|
||||||
|
for (int k = i; k<i+3 ; k++) {
|
||||||
|
for (int l = j; l<j+3 ; l++) {
|
||||||
|
|
||||||
|
// Recherche du max
|
||||||
|
if ((imgMax(k,l) <= max)&&(l!=ymax &&k!=xmax)) {
|
||||||
|
imgMax(k,l) = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
max = imgMax(k,l);
|
||||||
|
imgMax(xmax,ymax) = 0;
|
||||||
|
xmax = k;
|
||||||
|
ymax = l;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Recherche du min
|
||||||
|
if ((imgMin(k,l) >= min)&&(l!=ymin &&k!=xmin)) {
|
||||||
|
imgMin(k,l) = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
min = imgMin(k,l);
|
||||||
|
imgMin(xmin,ymin) = 0;
|
||||||
|
xmin = k;
|
||||||
|
ymin = l;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Affichage de l'image de max et min
|
||||||
|
CImgDisplay dispMax(imgMax,"Image de Max");
|
||||||
|
CImgDisplay dispMin(imgMin,"Image de Min");
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Partie 2: Moyenne //
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
CImg<unsigned char> imgMoyenne = (imgMax+imgMin)/2;
|
||||||
|
|
||||||
|
CImgDisplay dispMoyenne(imgMoyenne,"Image Moyenne");
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Partie 3: Suppression //
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
CImg<unsigned char> imgFin = imgLena - imgMoyenne;
|
||||||
|
|
||||||
|
CImgDisplay dispFin(imgFin,"Image Finale");
|
||||||
|
|
||||||
|
while (!dispBase.is_closed())
|
||||||
|
{
|
||||||
|
dispBase.wait();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user