TPCCLIB
Toggle main menu visibility
Loading...
Searching...
No Matches
libtpcmodext
cluster_tac.c
Go to the documentation of this file.
1
5
/*****************************************************************************/
6
7
/*****************************************************************************/
8
#include "
libtpcmodext.h
"
9
/*****************************************************************************/
10
11
/*****************************************************************************/
15
int
clusterTACs
(
17
IMG
*dimg,
19
IMG
*cimg,
21
int
nr,
23
DFT
*tac,
25
int
verbose
26
) {
27
if
(verbose>0) printf(
"clusterTACs(dimg, cimg, %d, tac, %d)\n"
, nr, verbose);
28
29
/* Check the arguments */
30
if
(dimg==NULL || cimg==NULL || nr<1 || tac==NULL)
return
(1);
31
if
(dimg->
dimt
<1 || cimg->
dimt
<1)
return
(1);
32
if
(cimg->
dimx
!=dimg->
dimx
|| cimg->
dimy
!=dimg->
dimy
|| cimg->
dimz
!=dimg->
dimz
)
33
return
(2);
34
35
/* Allocate memory for the TACs */
36
dftEmpty
(tac);
37
if
(
dftSetmem
(tac, dimg->
dimt
, nr+1))
return
(3);
38
39
/* Set TAC info */
40
tac->
voiNr
=0; tac->
frameNr
=dimg->
dimt
; tac->
_type
=1;
41
for
(
int
fi=0; fi<tac->
frameNr
; fi++) {
42
tac->
x1
[fi]=dimg->
start
[fi];
43
tac->
x2
[fi]=dimg->
end
[fi];
44
tac->
x
[fi] =dimg->
mid
[fi];
45
}
46
tac->
timetype
=
DFT_TIME_STARTEND
;
47
tac->
timeunit
=TUNIT_SEC;
48
strcpy(tac->
unit
,
imgUnit
(dimg->
unit
));
49
50
/* Calculate one cluster at a time */
51
float
y[dimg->
dimt
];
52
int
clusterID;
53
for
(clusterID=1; clusterID<=nr; clusterID++) {
54
char
buf[128]; snprintf(buf, 128,
"%06d"
, clusterID);
55
char
*p=buf+strlen(buf)-6;
56
snprintf(tac->
voi
[clusterID-1].
voiname
,
MAX_REGIONSUBNAME_LEN
+1,
"%s"
, p);
57
int
n=
imgsegmClusterMean
(dimg, cimg, clusterID, y, verbose);
58
if
(verbose>1) printf(
" clusterID%d -> %d pixels\n"
, clusterID, n);
59
if
(n<0)
return
(5);
else
if
(n==0)
return
(6);
60
for
(
int
fi=0; fi<tac->
frameNr
; fi++) tac->
voi
[clusterID-1].
y
[fi]=(
double
)y[fi];
61
tac->
voi
[clusterID-1].
size
=(double)n*dimg->
sizex
*dimg->
sizey
*dimg->
sizez
;
62
tac->
voiNr
++;
63
}
64
/* and once more for cluster 0, i.e. the thresholded pixels; */
65
/* note that it is possible that there is no cluster 0 at all */
66
clusterID=0;
67
sprintf(tac->
voi
[tac->
voiNr
].
voiname
,
"%06d"
, clusterID);
68
strcpy(tac->
voi
[tac->
voiNr
].
name
, tac->
voi
[tac->
voiNr
].
voiname
);
69
int
n=
imgsegmClusterMean
(dimg, cimg, clusterID, y, verbose);
70
if
(n<0)
return
(7);
71
if
(n>0) {
72
for
(
int
fi=0; fi<tac->
frameNr
; fi++) tac->
voi
[tac->
voiNr
].
y
[fi]=(
double
)y[fi];
73
tac->
voi
[tac->
voiNr
].
size
=(double)n*dimg->
sizex
*dimg->
sizey
*dimg->
sizez
;
74
tac->
voiNr
++;
75
}
76
77
return
(0);
78
}
79
/*****************************************************************************/
80
81
/*****************************************************************************/
clusterTACs
int clusterTACs(IMG *dimg, IMG *cimg, int nr, DFT *tac, int verbose)
Definition
cluster_tac.c:15
dftSetmem
int dftSetmem(DFT *data, int frameNr, int voiNr)
Definition
dft.c:57
dftEmpty
void dftEmpty(DFT *data)
Definition
dft.c:20
imgsegmClusterMean
int imgsegmClusterMean(IMG *dimg, IMG *cimg, int clusterID, float *avg, int verbose)
Definition
imgsegm.c:357
imgUnit
char * imgUnit(int dunit)
Definition
imgunits.c:315
DFT_TIME_STARTEND
#define DFT_TIME_STARTEND
Definition
libtpccurveio.h:439
MAX_REGIONSUBNAME_LEN
#define MAX_REGIONSUBNAME_LEN
Definition
libtpcmisc.h:158
libtpcmodext.h
Header file for libtpcmodext.
DFT
Definition
libtpccurveio.h:73
DFT::_type
int _type
Definition
libtpccurveio.h:125
DFT::timetype
int timetype
Definition
libtpccurveio.h:99
DFT::voi
Voi * voi
Definition
libtpccurveio.h:108
DFT::timeunit
int timeunit
Definition
libtpccurveio.h:85
DFT::x1
double * x1
Definition
libtpccurveio.h:104
DFT::voiNr
int voiNr
Definition
libtpccurveio.h:78
DFT::x2
double * x2
Definition
libtpccurveio.h:106
DFT::frameNr
int frameNr
Definition
libtpccurveio.h:76
DFT::x
double * x
Definition
libtpccurveio.h:102
DFT::unit
char unit[MAX_UNITS_LEN+1]
Definition
libtpccurveio.h:83
IMG
Definition
libtpcimgio.h:1657
IMG::sizex
float sizex
Definition
libtpcimgio.h:1714
IMG::dimx
unsigned short int dimx
Definition
libtpcimgio.h:1780
IMG::unit
char unit
Definition
libtpcimgio.h:1673
IMG::dimt
unsigned short int dimt
Definition
libtpcimgio.h:1778
IMG::sizey
float sizey
Definition
libtpcimgio.h:1716
IMG::start
float * start
Definition
libtpcimgio.h:1815
IMG::dimz
unsigned short int dimz
Definition
libtpcimgio.h:1784
IMG::dimy
unsigned short int dimy
Definition
libtpcimgio.h:1782
IMG::end
float * end
Definition
libtpcimgio.h:1817
IMG::mid
float * mid
Definition
libtpcimgio.h:1819
IMG::sizez
float sizez
Definition
libtpcimgio.h:1718
Voi::size
double size
Definition
libtpccurveio.h:56
Voi::voiname
char voiname[MAX_REGIONSUBNAME_LEN+1]
Definition
libtpccurveio.h:50
Voi::y
double * y
Definition
libtpccurveio.h:59
Voi::name
char name[MAX_REGIONNAME_LEN+1]
Definition
libtpccurveio.h:48
Generated on
for TPCCLIB by
1.17.0