Bonjour,
Dans mon école d'ingénieurs je dois réaliser un projet sur la reconstitution tomographique par la méthode du rétroprojection filtrée avec la bibliothèque CImg. J'ai jamais touché au C++ avant et j'ai beaucoup de difficultés. Là je crois avoir terminer le code mais ça marche pas. Est-ce que quelqu'un ici connait bien cette bibliothèque et pourrait m'aider?Je serait vraiment reconnaissant !

Je vais joindre mon code ici :

Je reçoit comme paramètre le sinogramme de mon image. Je calcul sa transformée de fourier. Puis je la filtre dans le domaine de fourier par un simple filtre rampe. Puis je retourne dans le domaine réel. Et là ce qui pose problème c'est la partie rétroprojection , que je réalise avec trois boucles for ( je sais pas si c'est comme ça que ça marche). Déjà ça plante à l'exécution si je traite tous les pixels ( 256) et quand je mets que 168 ça ne plante pas mais l'image que ça me donne n'est pas du tout celle que je dois avoir.


Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
63
64
65
66
67
#include "CImg.h"
#include <iostream>
#include <math.h>
 
using namespace cimg_library;
 
 
 
 
int interpolation(int k , int x , int y)
{
   float a = k*0.7 ;
   float b = x*cos(a)+y*sin(a);
   if(((b-fabs(b))>0.5)) return fabs(b)+1;
   else return fabs (b) ;
}
 
// Main
int main(int argc,char **argv)
{    int i , j , k;
	// Ouverture du fichier d'entree
	CImg<> my_img("sin.bmp");
	my_img.channel(0);
	my_img.resize(-100,256);
    CImgList<> fft_img_Y= my_img.get_FFT('y');
 
    CImg<> mod_fft_Y = (fft_img_Y[0].get_mul(fft_img_Y[0]) + fft_img_Y[1].get_mul(fft_img_Y[1])).get_sqrt();
             fft_img_Y[0] = fft_img_Y[0].get_mul(mod_fft_Y);
             fft_img_Y[1] = fft_img_Y[1].get_mul(mod_fft_Y);
 
     CImgList<> filtr_img_Y = fft_img_Y.get_FFT('y',true);
     CImg<> img_filtred = filtr_img_Y[0];
	img_filtred.resize(256,256);
 
 
    CImg<> img_finale = (my_img - my_img);
	img_finale.resize(256,256);
 
 
float a ; int d ;
 
 for(i=0;i<169;i++)
    {                         
        for (j=0;j<199;j++)
        {                            
          for(k=0;k<230;k++)
          { d = interpolation(k,i,j);
            a = a + (img_filtred (k,d))/250 ;
          } k=0;
          img_finale(i,j)=a;
          a=0;
        }
    }
 
 
 
 
	// Affichage final
	CImgDisplay dispSpatial(my_img,"Mon sinogramme");
	CImgDisplay dispSpatia(img_finale,"mon image");
 
	while (!dispSpatial.is_closed())
	{
		dispSpatial.wait();
	}
	return 0;
}
Voilà. J'espère que quelqu'un d'entre vous pourrais m'aider car le dernier délai c'est dans quelques jours sinon je prend un 0.
Merci d'avance!