VIP: Volume Image Processing


moment.h
Go to the documentation of this file.
1/****************************************************************************
2 * PROJECT : V.I.P. Library
3 * MODULE NAME : vip/moment.h * TYPE : Header
4 * AUTHOR : POUPON F. * CREATION : 26/11/1996
5 * VERSION : 0.1 * REVISION :
6 * LANGUAGE : C++ * EXAMPLE :
7 * DEVICE : Sun SPARC Station 5
8 ****************************************************************************
9 *
10 * DESCRIPTION : Calcul les moments d'une forme
11 *
12 ****************************************************************************
13 *
14 * USED MODULES : math.h - values.h - vip/alloc.h - vip/complex.h
15 *
16 ****************************************************************************
17 * REVISIONS : DATE | AUTHOR | DESCRIPTION
18 *--------------------|--------------|---------------------------------------
19 * / / | |
20 ****************************************************************************/
21
22#ifndef VIP_MOMENT_H
23#define VIP_MOMENT_H
24
25#ifdef __cplusplus
26 extern "C" {
27#endif
28
29#include <math.h>
30#include <float.h>
31#include <vip/alloc.h>
32#include <vip/vcomplex.h>
33
34#define M_SUB -1
35#define M_ADD 1
36
37#define M_2D 2
38#define M_3D 3
39
40#define M_NORMAL 100
41#define M_LEGENDRE 101
42
43#define IsNull(a) ((a)+(double)((a) == 0.0))
44#define IsAlone(a) (double)((a-1) != 0.0)
45
46#define Module(a,b,c) (sqrt(Sq(a)+Sq(b)+Sq(c)))
47#define Scalaire(a,b,c,d,e,f) ((a)*(d)+(b)*(e)+(c)*(f))
48
49typedef struct
50{ double sum; /* nombre de voxels de l'objet 3D */
51 double m0; /* aussi egal a mu0 */
52 double m1[3]; /* 0:m100; 1:m010; 2:m001 */
53 double mu2[6]; /* 0:mu200; 1:mu020; 2:mu002; 3:mu110; 4:mu101; 5:mu011 */
54 double mu3[10]; /* 0:mu300; 1:mu030; 2:mu003; 3:mu210; 4:mu201;
55 5:mu120; 6:mu021; 7:mu102; 8:mu012; 9:mu111 */
56 double mx, my, mz; /* centre de gravite */
57 Complex_VDOUBLE nu0; /* moment complex nu0 */
58 Complex_VDOUBLE nu1[3]; /* 0:nu1,-1; 1:nu1,0; 2:nu1,1 */
59 Complex_VDOUBLE nu2[5]; /* 0:nu2,-2; 1:nu2,-1; 2:nu2,0; 3:nu2,1; 4:nu2,2 */
60 Complex_VDOUBLE nu3[7]; /* 0:nu3,-3; 1:nu3,-2; 2:nu3,-1; 3:nu3,0;
61 4:nu3,1; 5:nu3,2; 6:nu3,3 */
62 double I[12]; /* 0:I^2_00; 1:I^2_22; 2:I^2_222; 3:I^3_11; 4:I^3_33;
63 5:I^3_1113; 6:I^3_1133; 7:I^3_1333; 8:I^3_3333;
64 9:I^2,3_112; 10:I^2,3_123; 11:I^2,3_233 */
65 double ct, cx, cy, cz; /* corrections d'anisotropie de voxel */
66 VipVector_VDOUBLE *Lambda; /* valeurs propres pour l'orientation */
67 VipMatrix_VDOUBLE *I2; /* matrice d'inertie, et vecteurs propres (orientation) */
68} Moment;
69
70typedef struct
71{ double sum; /* nombre de pixels de l'objet 2D */
72 double m0; /* aussi egal a mu0 */
73 double m1[2]; /* 0:m10; 1:m01 */
74 double mu2[3]; /* 0:mu20; 1:mu02: 2:mu11 */
75 double mu3[4]; /* 0:mu30; 1:mu03; 2:mu21; 3:mu12 */
76 double mx, my; /* centre de gravite */
77 double I[7]; /* invariants : Phi0 a Phi6 (Cf HU-62) */
78 double ct, cx, cy; /* corrections d'anisotropie de pixel */
79 VipVector_VDOUBLE *Lambda; /* valeurs propres pour l'orientation */
80 VipMatrix_VDOUBLE *I2; /* matrice d'inertie, et vecteurs propres (orientation) */
81} Moment2D;
82
83typedef struct
85 double l0;
86 double l1[3];
87 double lu2[6];
88 double lu3[10];
89 double lx, ly, lz;
90} Legendre;
91
92typedef struct
94 double l0;
95 double l1[2];
96 double lu2[3];
97 double lu3[4];
98 double lx, ly;
100
101/*----------------------------------------------------------------------------*/
103 Volume *vol
104);
105/*----------------------------------------------------------------------------*/
106
107/*----------------------------------------------------------------------------*/
108extern void VipFreeMoment(
109 Moment *mom
110);
111/*----------------------------------------------------------------------------*/
112
113/*----------------------------------------------------------------------------*/
115 Volume *vol
116);
117/*----------------------------------------------------------------------------*/
118
119/*----------------------------------------------------------------------------*/
121 Legendre *leg
122);
123/*----------------------------------------------------------------------------*/
124
125/*----------------------------------------------------------------------------*/
126extern void VipMomentCopy(
127 Moment *mom1,
128 Moment *mom2
129);
130/*----------------------------------------------------------------------------*/
131
132/*----------------------------------------------------------------------------*/
133extern void VipMomentCopy2D(
134 Moment2D *mom1,
135 Moment2D *mom2
136);
137/*----------------------------------------------------------------------------*/
138
139/*----------------------------------------------------------------------------*/
141 Legendre *leg1,
142 Legendre *leg2
143);
144/*----------------------------------------------------------------------------*/
145
146/*----------------------------------------------------------------------------*/
148 Legendre2D *leg1,
149 Legendre2D *leg2
150);
151/*----------------------------------------------------------------------------*/
152
153/*----------------------------------------------------------------------------*/
155 Moment *mom,
156 double x,
157 double y,
158 double z,
159 int dir
160);
161/*----------------------------------------------------------------------------*/
162
163/*----------------------------------------------------------------------------*/
165 Moment *mom
166);
167/*----------------------------------------------------------------------------*/
168
169/*----------------------------------------------------------------------------*/
171 Moment *mom
172);
173/*----------------------------------------------------------------------------*/
174
175/*----------------------------------------------------------------------------*/
177 Moment *mom
178);
179/*----------------------------------------------------------------------------*/
180
181/*----------------------------------------------------------------------------*/
183 Volume *vol,
184 Vip_U16BIT label,
185 Moment *mom,
186 int dir
187);
188/*----------------------------------------------------------------------------*/
189
190/*----------------------------------------------------------------------------*/
192 Volume *vol,
193 Vip_U16BIT label,
194 Moment *mom,
195 int dir,
196 int mask
197);
198/*----------------------------------------------------------------------------*/
199
200/*----------------------------------------------------------------------------*/
202 Volume *vol,
203 Vip_U16BIT label,
204 int dir
205);
206/*----------------------------------------------------------------------------*/
207
208/*----------------------------------------------------------------------------*/
210 Volume *vol,
211 Vip_U16BIT label,
212 Moment *mom,
213 int dir
214);
215/*----------------------------------------------------------------------------*/
216
217/*----------------------------------------------------------------------------*/
219 Volume *vol,
220 Vip_U16BIT label,
221 Moment *mom,
222 int dir,
223 int mask
224);
225/*----------------------------------------------------------------------------*/
226
227/*----------------------------------------------------------------------------*/
229 Volume *vol,
230 Vip_U16BIT label,
231 int dir
232);
233/*----------------------------------------------------------------------------*/
234
235/*----------------------------------------------------------------------------*/
237 Volume *vol,
238 Vip_U16BIT label,
239 int dir,
240 int mask
241);
242/*----------------------------------------------------------------------------*/
243
244/*----------------------------------------------------------------------------*/
246 Moment *mom,
247 int x,
248 int y,
249 int z,
250 int dir
251);
252/*----------------------------------------------------------------------------*/
253
254/*----------------------------------------------------------------------------*/
256 Legendre *leg
257);
258/*----------------------------------------------------------------------------*/
259
260/*----------------------------------------------------------------------------*/
262 Volume *vol,
263 Vip_U16BIT label,
264 Legendre *leg,
265 int dir
266);
267/*----------------------------------------------------------------------------*/
268
269/*----------------------------------------------------------------------------*/
271 Volume *vol,
272 Vip_U16BIT label,
273 int dir
274);
275/*----------------------------------------------------------------------------*/
276
277/*----------------------------------------------------------------------------*/
279 FILE *stream,
280 Moment *mom,
281 char *filename
282);
283/*----------------------------------------------------------------------------*/
284
285/*----------------------------------------------------------------------------*/
287 FILE *stream,
288 Legendre *leg,
289 char *filename
290);
291/*----------------------------------------------------------------------------*/
292
293/*----------------------------------------------------------------------------*/
295 FILE *stream,
296 Moment *mom
297);
298/*----------------------------------------------------------------------------*/
299
300/*----------------------------------------------------------------------------*/
302 FILE *stream,
303 Moment *mom
304);
305/*----------------------------------------------------------------------------*/
306
307/*----------------------------------------------------------------------------*/
308extern int VipPrintMoment(
309 Moment *mom,
310 char *filename,
311 char *resultfile
312);
313/*----------------------------------------------------------------------------*/
314
315/*----------------------------------------------------------------------------*/
317 Legendre *leg,
318 char *filename,
319 char *resultfile
320);
321/*----------------------------------------------------------------------------*/
322
323/*----------------------------------------------------------------------------*/
325 Volume *vol
326);
327/*----------------------------------------------------------------------------*/
328
329/*----------------------------------------------------------------------------*/
330extern void VipFreeMoment2D(
331 Moment2D *mom
332);
333/*----------------------------------------------------------------------------*/
334
335/*----------------------------------------------------------------------------*/
337 Volume *vol
338);
339/*----------------------------------------------------------------------------*/
340
341/*----------------------------------------------------------------------------*/
343 Legendre2D *leg
344);
345/*----------------------------------------------------------------------------*/
346
347/*----------------------------------------------------------------------------*/
349 Moment2D *mom,
350 double x,
351 double y,
352 int dir
353);
354/*----------------------------------------------------------------------------*/
355
356/*----------------------------------------------------------------------------*/
358 Moment2D *mom
359);
360/*----------------------------------------------------------------------------*/
361
362/*----------------------------------------------------------------------------*/
364 Volume *vol,
365 Vip_U16BIT label,
366 Moment2D *mom,
367 int dir
368);
369/*----------------------------------------------------------------------------*/
370
371/*----------------------------------------------------------------------------*/
373 Volume *vol,
374 Vip_U16BIT label,
375 int dir
376);
377/*----------------------------------------------------------------------------*/
378
379/*----------------------------------------------------------------------------*/
381 Volume *vol,
382 Vip_U16BIT label,
383 Moment2D *mom,
384 int dir
385);
386/*----------------------------------------------------------------------------*/
387
388/*----------------------------------------------------------------------------*/
390 Volume *vol,
391 Vip_U16BIT label,
392 int dir
393);
394/*----------------------------------------------------------------------------*/
395
396/*----------------------------------------------------------------------------*/
398 Moment2D *mom,
399 int x,
400 int y,
401 int dir
402);
403/*----------------------------------------------------------------------------*/
404
405/*----------------------------------------------------------------------------*/
407 Legendre2D *leg
408);
409/*----------------------------------------------------------------------------*/
410
411/*----------------------------------------------------------------------------*/
413 Volume *vol,
414 Vip_U16BIT label,
415 Legendre2D *leg,
416 int dir
417);
418/*----------------------------------------------------------------------------*/
419
420/*----------------------------------------------------------------------------*/
422 Volume *vol,
423 Vip_U16BIT label,
424 int dir
425);
426/*----------------------------------------------------------------------------*/
427
428/*----------------------------------------------------------------------------*/
430 FILE *stream,
431 Moment2D *mom,
432 char *filename
433);
434/*----------------------------------------------------------------------------*/
435
436/*----------------------------------------------------------------------------*/
438 FILE *stream,
439 Legendre2D *leg,
440 char *filename
441);
442/*----------------------------------------------------------------------------*/
443
444/*----------------------------------------------------------------------------*/
446 FILE *stream,
447 Moment2D *mom
448);
449/*----------------------------------------------------------------------------*/
450
451/*----------------------------------------------------------------------------*/
453 FILE *stream,
454 Moment2D *mom
455);
456/*----------------------------------------------------------------------------*/
457
458/*----------------------------------------------------------------------------*/
460 Moment2D *mom,
461 char *filename,
462 char *resultfile
463);
464/*----------------------------------------------------------------------------*/
465
466/*----------------------------------------------------------------------------*/
468 Legendre2D *leg,
469 char *filename,
470 char *resultfile
471);
472/*----------------------------------------------------------------------------*/
473
474#ifdef __cplusplus
475 }
476#endif
477
478#endif
void VipFreeLegendreMoment(Legendre *leg)
void VipMomentCopy(Moment *mom1, Moment *mom2)
Moment * VipCreateAndComputeMomentAndInvariant(Volume *vol, Vip_U16BIT label, int dir)
void VipFreeMoment2D(Moment2D *mom)
void VipComputeMomentM(Volume *vol, Vip_U16BIT label, Moment *mom, int dir, int mask)
Moment * VipCreateAndComputeMoment(Volume *vol, Vip_U16BIT label, int dir)
Legendre * VipCreateAndComputeMomentAndLegendreMoment(Volume *vol, Vip_U16BIT label, int dir)
void VipPrintStreamInvariantForPCA(FILE *stream, Moment *mom)
Moment * VipCreateAndComputeMomentAndInvariantM(Volume *vol, Vip_U16BIT label, int dir, int mask)
int VipComputeMomentAndLegendreMoment2D(Volume *vol, Vip_U16BIT label, Legendre2D *leg, int dir)
int VipUpdateMomentAndInvariant2D(Moment2D *mom, int x, int y, int dir)
void VipPrintStreamInvariantForCovarianceMatrix2D(FILE *stream, Moment2D *mom)
Moment2D * VipCreateMoment2D(Volume *vol)
int VipPrintLegendreMoment(Legendre *leg, char *filename, char *resultfile)
int VipPrintMoment2D(Moment2D *mom, char *filename, char *resultfile)
int VipPrintMoment(Moment *mom, char *filename, char *resultfile)
void VipAddOrSubPointToMoment(Moment *mom, double x, double y, double z, int dir)
void VipComputeMoment(Volume *vol, Vip_U16BIT label, Moment *mom, int dir)
int VipUpdateMomentAndInvariant(Moment *mom, int x, int y, int z, int dir)
Legendre2D * VipCreateLegendreMoment2D(Volume *vol)
void VipPrintStreamMoment(FILE *stream, Moment *mom, char *filename)
void VipLegendreMomentCopy2D(Legendre2D *leg1, Legendre2D *leg2)
void VipPrintStreamInvariantForPCA2D(FILE *stream, Moment2D *mom)
Legendre * VipCreateLegendreMoment(Volume *vol)
void VipComputeMoment2D(Volume *vol, Vip_U16BIT label, Moment2D *mom, int dir)
int VipComputeMomentInvariants(Moment *mom)
Legendre2D * VipCreateAndComputeMomentAndLegendreMoment2D(Volume *vol, Vip_U16BIT label, int dir)
void VipFreeLegendreMoment2D(Legendre2D *leg)
int VipComputeMomentAndInvariant2D(Volume *vol, Vip_U16BIT label, Moment2D *mom, int dir)
int VipComputeMomentAndInvariant(Volume *vol, Vip_U16BIT label, Moment *mom, int dir)
Moment * VipCreateMoment(Volume *vol)
void VipPrintStreamLegendreMoment2D(FILE *stream, Legendre2D *leg, char *filename)
int VipComputeLegendreMoment2D(Legendre2D *leg)
int VipComputeInvariant(Moment *mom)
int VipComputeInvariant2D(Moment2D *mom)
void VipPrintStreamLegendreMoment(FILE *stream, Legendre *leg, char *filename)
int VipComputeMomentAndLegendreMoment(Volume *vol, Vip_U16BIT label, Legendre *leg, int dir)
Moment2D * VipCreateAndComputeMoment2D(Volume *vol, Vip_U16BIT label, int dir)
void VipGetComplexMoment(Moment *mom)
void VipPrintStreamMoment2D(FILE *stream, Moment2D *mom, char *filename)
int VipComputeLegendreMoment(Legendre *leg)
int VipPrintLegendreMoment2D(Legendre2D *leg, char *filename, char *resultfile)
void VipAddOrSubPointToMoment2D(Moment2D *mom, double x, double y, int dir)
void VipFreeMoment(Moment *mom)
int VipComputeMomentAndInvariantM(Volume *vol, Vip_U16BIT label, Moment *mom, int dir, int mask)
void VipLegendreMomentCopy(Legendre *leg1, Legendre *leg2)
void VipPrintStreamInvariantForCovarianceMatrix(FILE *stream, Moment *mom)
Moment2D * VipCreateAndComputeMomentAndInvariant2D(Volume *vol, Vip_U16BIT label, int dir)
void VipMomentCopy2D(Moment2D *mom1, Moment2D *mom2)
double l1[2]
Definition moment.h:95
double lu3[4]
Definition moment.h:97
double ly
Definition moment.h:98
double lu2[3]
Definition moment.h:96
Moment2D * moment
Definition moment.h:93
double l0
Definition moment.h:94
double lx
Definition moment.h:98
double lu3[10]
Definition moment.h:88
double l0
Definition moment.h:85
double lu2[6]
Definition moment.h:87
double ly
Definition moment.h:89
Moment * moment
Definition moment.h:84
double lz
Definition moment.h:89
double l1[3]
Definition moment.h:86
double lx
Definition moment.h:89
double mu2[3]
Definition moment.h:74
double mu3[4]
Definition moment.h:75
double cx
Definition moment.h:78
double m0
Definition moment.h:72
double cy
Definition moment.h:78
double I[7]
Definition moment.h:77
double sum
Definition moment.h:71
VipVector_VDOUBLE * Lambda
Definition moment.h:79
VipMatrix_VDOUBLE * I2
Definition moment.h:80
double ct
Definition moment.h:78
double mx
Definition moment.h:76
double m1[2]
Definition moment.h:73
double my
Definition moment.h:76
double m0
Definition moment.h:51
Complex_VDOUBLE nu1[3]
Definition moment.h:58
VipMatrix_VDOUBLE * I2
Definition moment.h:67
double cz
Definition moment.h:65
double cx
Definition moment.h:65
VipVector_VDOUBLE * Lambda
Definition moment.h:66
double mz
Definition moment.h:56
double I[12]
Definition moment.h:62
double my
Definition moment.h:56
Complex_VDOUBLE nu2[5]
Definition moment.h:59
double ct
Definition moment.h:65
double sum
Definition moment.h:50
Complex_VDOUBLE nu0
Definition moment.h:57
double cy
Definition moment.h:65
double m1[3]
Definition moment.h:52
double mx
Definition moment.h:56
Complex_VDOUBLE nu3[7]
Definition moment.h:60
double mu2[6]
Definition moment.h:53
double mu3[10]
Definition moment.h:54
unsigned short Vip_U16BIT
Definition structure.h:92