Bonjour a tous...

Voila je dois remplacer une librairie qui me fait ce calcul, mais j'ai un temps de calcul bien supérieur au leur. Je voulais savoir si quelqu'un a des idées d'optimisation qui pourrait diminuer cet écart de temps de calcul (2 à 3 fois supérieur que ce qu'il est possible de faire).

Pour le contexte, c'est l'extraction d'une coupe 2D dans un volume 3D.

J'ai calculé un vecteur de déplacement équivalent au déplacement entre deux pixels. 1 Sur l'axe des X l'autre sur l'axe des Y. a chaque itération (et donc a chaque pixel) j'effectue mon déplacement, regarde le voxels qui contient le point et en extrait la données.


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
int CVolume::RasterizeSliceNearest(void* aiSlice,
							const double* adOrigVOL, 
							const double* adVectorDepVOL,
							const double* adResVOL, 
							const int iNbWidthVIEW, 
							const int iNbHeightVIEW,	
							const int iValMinVOL)
{
	double adCurPosVOL[3];
	double adOrigPosVOL[3];
	double adVectorPosVOLX[3];
	double adVectorPosVOLY[3];
	int aiVoxelVOL[3];
	short* aiVolumeTemp;
	unsigned char* acVolumeTemp;
	int iPos=0;
 
	for(int k = 0 ; k<3;k++)
	{
		adOrigPosVOL[k] = adOrigVOL[k]/adResVOL[k];
		adVectorPosVOLX[k] = adVectorDepVOL[k]/adResVOL[k];
		adVectorPosVOLY[k] = adVectorDepVOL[k+3]/adResVOL[k];
	}
 
	aiVolumeTemp = (short*)m_aiPixelsValue;
	for(int i=0; i<iNbHeightVIEW;i++)
	{
		adOrigPosVOL[0]+=adVectorPosVOLY[0];
		adOrigPosVOL[1]+=adVectorPosVOLY[1];
		adOrigPosVOL[2]+=adVectorPosVOLY[2];
		adCurPosVOL[0] = adOrigPosVOL[0];
		adCurPosVOL[1] = adOrigPosVOL[1];
		adCurPosVOL[2] = adOrigPosVOL[2];
		for(int j=0;j<iNbWidthVIEW;j++)
		{
			adCurPosVOL[0] += adVectorPosVOLX[0];
			adCurPosVOL[1] += adVectorPosVOLX[1];
			adCurPosVOL[2] += adVectorPosVOLX[2];
			aiVoxelVOL[0] = (int)adCurPosVOL[0];
			aiVoxelVOL[1] = (int)adCurPosVOL[1];
			aiVoxelVOL[2] = (int)adCurPosVOL[2];
			if(adCurPosVOL[0]>=0&&adCurPosVOL[1]>=0&&adCurPosVOL[2]>=0
					&&aiVoxelVOL[0]<GetVolDimWidth()&&aiVoxelVOL[1]<GetVolDimHeight()&&aiVoxelVOL[2]<GetVolDimDepth())
			{
				((short*)aiSlice)[iPos] = (short)aiVolumeTemp[aiVoxelVOL[0]+m_aiDecalInWidthPos[aiVoxelVOL[1]]+m_aiDecalInWidthHeightPos[aiVoxelVOL[2]]];//Aislice est de type void * (tableau à 1 dimension)
//m_aiDecalInWidthHeightPos contient les déplacement de mon tableau
 
			}
			else
			{
				((short*)aiSlice)[iPos] = (short)iValMinVOL;
			}
			iPos++;
		}
	}
return 0;
}