TPCCLIB
|
Functions for segmentation of 4D PET images. More...
#include "libtpcimgp.h"
Go to the source code of this file.
Functions | |
int | imgsegmThresholdMask (IMG *img, float minValue, float maxValue, IMG *timg) |
int | imgsegmThresholdByMask (IMG *img, IMG *template, float minValue, float maxValue) |
int | imgsegmThreshold (IMG *img, float minValue, float maxValue) |
int | imgsegmMaskToCluster (IMG *img) |
int | imgsegmFindMaxOutsideClusters (IMG *sumimg, IMG *cluster, float *max, int *plane, int *row, int *col) |
int | imgsegmClusterExpand (IMG *cimg, IMG *simg, IMG *dimg, int clusterID, int pi, int ri, int ci, int pj, int rj, int cj, float CVlim, float CClim, int verbose) |
float | imgsegmPearson (float *x, float *y, long long nr) |
int | imgsegmClusterMean (IMG *dimg, IMG *cimg, int clusterID, float *avg, int verbose) |
int | imgsegmCheckNeighbours (IMG *cimg, int pi, int ri, int ci) |
int | imgsegmFindBestNeighbour (IMG *dimg, IMG *cimg, int pi, int ri, int ci) |
int | imgsegmSimilar (IMG *input, int smoothDim, int smoothNr, IMG *output, int verbose) |
int | imgsegmCalcMRL (float y1[], float y2[], long long n) |
Functions for segmentation of 4D PET images.
Definition in file imgsegm.c.
int imgsegmCalcMRL | ( | float | y1[], |
float | y2[], | ||
long long | n ) |
Calculates the maximum run length between given n length arrays of data.
y1 | Array 1. |
y2 | Array 2. |
n | Length of arrays. |
Definition at line 567 of file imgsegm.c.
Referenced by imgsegmSimilar().
int imgsegmCheckNeighbours | ( | IMG * | cimg, |
int | pi, | ||
int | ri, | ||
int | ci ) |
Checks if neighbours of the specified pixel belong to any cluster.
cimg | Cluster image. |
pi | Pixel definition [z,y,x]. |
ri | Pixel definition [z,y,x]. |
ci | Pixel definition [z,y,x]. |
Definition at line 398 of file imgsegm.c.
int imgsegmClusterExpand | ( | IMG * | cimg, |
IMG * | simg, | ||
IMG * | dimg, | ||
int | clusterID, | ||
int | pi, | ||
int | ri, | ||
int | ci, | ||
int | pj, | ||
int | rj, | ||
int | cj, | ||
float | CVlim, | ||
float | CClim, | ||
int | verbose ) |
Expands the cluster locally to its neighbour pixels.
Calls itself recursively until neighbouring pixels do not belong to cluster. Because of recursion, program which uses this function needs a large space for stack: add the following line to your program: unsigned _stklen = 4194304;
cimg | pointer to cluster image data. |
simg | pointer to sum image data. |
dimg | pointer to dynamic image data. |
clusterID | number of cluster to be tested. |
pi | coordinates of test pixel [z,y,x]. |
ri | coordinates of test pixel [z,y,x]. |
ci | coordinates of test pixel [z,y,x]. |
pj | coordinates of cluster start [z,y,x]. |
rj | coordinates of cluster start [z,y,x]. |
cj | coordinates of cluster start [z,y,x]. |
CVlim | CV limit. |
CClim | CC limit. |
verbose | Verbose level; if zero, then only warnings are printed into stderr. |
Definition at line 219 of file imgsegm.c.
Referenced by imgsegmClusterExpand().
Calculates the average of pixels belonging to the specified cluster, and returns this average for each frame in the specified float array.
Cluster pixels do not have to be adjacent!
dimg | Dynamic image. |
cimg | Cluster image. |
clusterID | Cluster number 0... |
avg | Pointer to a float array where cluster average TAC is written. |
verbose | Verbose level; if zero, then only warnings are printed into stderr. |
Definition at line 357 of file imgsegm.c.
Referenced by clusterTACs().
Combines this pixel to the cluster of the neighbour which has the best correlation.
All neighbours of the specified pixel must belong to some cluster (must be checked before calling this function).
dimg | Dynamic image. |
cimg | Cluster image. |
pi | Pixel definition [z,y,x]. |
ri | Pixel definition [z,y,x]. |
ci | Pixel definition [z,y,x]. |
Definition at line 427 of file imgsegm.c.
int imgsegmFindMaxOutsideClusters | ( | IMG * | sumimg, |
IMG * | cluster, | ||
float * | max, | ||
int * | plane, | ||
int * | row, | ||
int * | col ) |
Finds the maximum sumimg pixel value, excluding all pixels which already belong to clusters (cluster>=0).
sumimg | Integral image. |
cluster | Cluster image. |
max | Found max value. |
plane | Found max pixel [Z,y,x]. |
row | Found max pixel [z,Y,x]. |
col | Found max pixel [z,y,X]. |
Definition at line 166 of file imgsegm.c.
int imgsegmMaskToCluster | ( | IMG * | img | ) |
float imgsegmPearson | ( | float * | x, |
float * | y, | ||
long long | nr ) |
Calculates Pearson's correlation coefficient between x[] and y[] values.
Not corrected for sample size.
x | x axis values. |
y | y axis values. |
nr | nr of samples. |
Definition at line 322 of file imgsegm.c.
Referenced by imgsegmClusterExpand(), and imgsegmFindBestNeighbour().
Computes a smoothed image from the specified dynamic image with noise.
The TACs inside a matrix smoothDim*smoothDim*smoothDim are sorted by the MRL and AUC, and each TAC is replaced by the mean of the best smoothNr TACs. This function allocates memory for output and copies the header info.
input | Dynamic input image. |
smoothDim | Smoothing mask dimensions; either 3 or 5 (default). |
smoothNr | Nr of TACs to average; default is 9. |
output | Smoothed image. |
verbose | Verbose level; if zero, then only warnings are printed into stderr. |
Definition at line 478 of file imgsegm.c.
int imgsegmThreshold | ( | IMG * | img, |
float | minValue, | ||
float | maxValue ) |
Sets values <minValue to zero, and values >maxValue to maxValue.
img | Dynamic or static image. |
minValue | Min pixel value. |
maxValue | Max pixel value. |
Sets pixel values in img to minValue, if corresponding pixel value in the mask is == 2, and to maxValue, if mask value is == 1.
Only first plane of the mask is used.
img | Dynamic image which is modified based on the mask. |
template | Mask image. |
minValue | This value is put into img if template value is =2. |
maxValue | This value is put into img if template value is =1. |
Allocate and fill a mask image based on the specified image and threshold values.
If pixel value in original image is <minValue, sets the mask pixel to 1, if >maxValue, sets mask pixel to 2, and to 0, if value is between minValue and maxValue. Only first frame is used, allocated and filled.
img | Pointer to original (static) image. |
minValue | Lower threshold limit. |
maxValue | Upper threshold limit. |
timg | Pointer to initiated and empty mask image. |
Definition at line 39 of file imgsegm.c.