TPCCLIB
|
Header file for libtpcimgp. More...
#include "tpcclibConfig.h"
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdint.h>
#include <stdlib.h>
#include <strings.h>
#include <ctype.h>
#include <float.h>
#include <unistd.h>
#include <locale.h>
#include <time.h>
#include "libtpcmisc.h"
#include "libtpcimgio.h"
Go to the source code of this file.
Data Structures | |
struct | point |
Macros | |
#define | PET_GRAYSCALE 1 |
#define | PET_GRAYSCALE_INV 2 |
#define | PET_RAINBOW 3 |
#define | PET_RAINBOW_WB 4 |
Functions | |
int | imgArithm (IMG *img1, IMG *img2, char operation, float ulimit, int verbose) |
int | imgArithmConst (IMG *img, float operand, char operation, float ulimit, int verbose) |
int | imgArithmFrame (IMG *img1, IMG *img2, char operation, float ulimit, int verbose) |
int | imgLn (IMG *img) |
int | imgLog10 (IMG *img) |
int | imgAbs (IMG *img) |
int | imgInv (IMG *img) |
int | imgFrameIntegral (IMG *img, int first, int last, IMG *iimg, int verbose) |
int | imgRawCountsPerTime (IMG *img, int operation) |
int | imgConvertUnit (IMG *img, char *unit) |
int | imgAUMC (IMG *img, IMG *oimg, int verbose) |
int | imgMRT (IMG *img, IMG *oimg, int verbose) |
int | imgAverageTAC (IMG *img, float *tac) |
int | imgAverageMaskTAC (IMG *img, IMG *timg, float *tac) |
int | imgAverageAUC (IMG *img, float *avgauc) |
int | imgMaskTAC (IMG *img, IMG *mask, double *tac, int verbose) |
int | imgMaskRoiNr (IMG *img, INTEGER_LIST *list) |
int | imgVoiMaskTAC (IMG *img, IMG *mask, int mv, double *tac, int verbose) |
int | imgGaussianFIRFilter (IMG *img, float xsd, float ysd, float zsd, double tolerance, int verbose) |
int | imgGaussianAMFilter (IMG *img, float xsd, float ysd, float zsd, int passNr, double tolerance, int verbose) |
int | filterAMGaussian (double *a, int n, int passNr, double nu, double scale, int termNr) |
int | filterHSSBE (int n, int r) |
double | filterAMLB (double *a, int n, double nu, int termNr) |
int | imgGaussianEBoxFilter (IMG *img, float xsd, float ysd, float zsd, int passNr, int verbose) |
int | filterEbox (double *a, int n, double wob, double wib, int rib, int passNr) |
int | fMean1DFilter (float *data, const int n, const int s) |
int | imgMeanFilter (IMG *img, int xn, int yn, int zn, int tn, int verbose) |
void | imgFlipHorizontal (IMG *img) |
void | imgFlipVertical (IMG *img) |
void | imgFlipPlanes (IMG *img) |
int | imgFlipRight (IMG *img) |
int | imgFlipAbove (IMG *img) |
int | imgMeanZ (IMG *img1, IMG *img2) |
int | imgFramesCheck (IMG *img, int verbose) |
int | imgFrameGapFill (IMG *img, int verbose) |
int | imgDeleteFrameOverlap_old (IMG *img) |
int | imgDeleteFrameOverlap (IMG *img) |
int | imgSmoothOverFrames (IMG *img, int n) |
int | imgGetFrameDiff (IMG *img, IMG *dimg, IMG *mimg, int verbose) |
int | imgGetFrameDyn (IMG *img, IMG *iimg, IMG *dimg, int verbose) |
int | imgSetScanner (IMG *img, int scanner_type) |
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 *cluster, IMG *sum, IMG *dynamic, 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) |
int | imgThresholding (IMG *img, float threshold_level, long long *thr_nr) |
int | imgThresholdingLowHigh (IMG *img, float lower_threshold_level, float upper_threshold_level, IMG *timg, long long *lower_thr_nr, long long *upper_thr_nr) |
int | imgOutlierFilter (IMG *img, float limit) |
int | imgThresholdMaskCount (IMG *img, float minValue, float maxValue, IMG *timg, long long *count) |
int | imgThresholdMask (IMG *img, float minValue, float maxValue, IMG *timg) |
int | imgThresholdByMask (IMG *img, IMG *templt, float thrValue) |
void | imgCutoff (IMG *image, float cutoff, int mode) |
int | imgRegionGrowingByThreshold (IMG *img, const int sz, const int sy, const int sx, float lthr, float uthr, IMG *mask, int verbose) |
int | tiffWriteImg (IMG *img, int plane, int frame, float *maxvalue, int colorscale, char *fname, int matXdim, int matYdim, int verbose, char *status) |
int | img2cube (IMG *img1, int dim, IMG *img2) |
void | imgScale (IMG *src, IMG *targ, float zoom, int method) |
void | integerScale (int frame, float ***src, float **targ, int width, int height, int zoom) |
int | imgShrink (IMG *img1, IMG *img2, int doz) |
int | imgSwell (IMG *img1, IMG *img2, int doz) |
long long | imgMaskCount (IMG *img) |
int | imgMaskErode (IMG *img, IMG *se) |
int | imgMaskDilate (IMG *img, IMG *se) |
int | imgStructuringElement (IMG *img, const int structuring_element, int verbose) |
void | imgMaskInvert (IMG *img) |
int | imgMaskConjunction (IMG *mask1, IMG *mask2) |
int | imgMaskRegionLabeling (IMG *mask1, IMG *mask2, int *n, int verbose) |
int | imgMaskFloodFill (IMG *m, int sz, int sy, int sx, int label, long long *n, int verbose) |
int | imgMaskCloak (IMG *img, int dim, float id) |
int | pRound (float) |
float | getDistance (point, point) |
float | getAngle (point, point) |
Header file for libtpcimgp.
Definition in file libtpcimgp.h.
#define PET_GRAYSCALE 1 |
#define PET_GRAYSCALE_INV 2 |
PET image color scale
Definition at line 34 of file libtpcimgp.h.
#define PET_RAINBOW 3 |
#define PET_RAINBOW_WB 4 |
|
extern |
1D Alvarez-Mazorra Gaussian filtering.
a | Pointer to source data array, overwritten by the results. |
n | Sample number. |
passNr | Number of filtering passes; usually 4. |
nu | Filter coefficient. |
scale | Filter scale. |
termNr | Number of terms needed to approximate the sum with required accuracy for the left boundary. |
Definition at line 314 of file imgfilter.c.
Referenced by imgGaussianAMFilter().
|
extern |
Left boundary for 1D Alvarez-Mazorra Gaussian filtering.
a | Pointer to source data array; not modified. |
n | Sample number. |
nu | Filtering parameter. |
termNr | Number of terms. |
Definition at line 372 of file imgfilter.c.
Referenced by filterAMGaussian().
|
extern |
1D extended box filtering .
a | Pointer to source data array. |
n | Sample number. |
wob | Weight of the outer box. |
wib | Weight of the inner box. |
rib | Radius of the inner box. |
passNr | Number of filtering passes. |
Definition at line 558 of file imgfilter.c.
Referenced by imgGaussianEBoxFilter().
|
externinline |
Half-sample symmetric boundary extension.
n | Sample number. |
r | Requested sample, possibly outside array[0..N-1]. |
Definition at line 352 of file imgfilter.c.
Referenced by filterAMLB(), filterEbox(), and imgGaussianFIRFilter().
|
extern |
In-place mean 1D-filtering.
data | Pointer to array to be filtered. |
n | Array size. |
s | Filter size; should be odd number 3,5,7,... but not verified here. |
Definition at line 595 of file imgfilter.c.
Referenced by imgMeanFilter().
Calculates xy-projection of angle FCX in degrees, where F=first point, C=centre point and X=point with higher x coordinate (y and z coordinate remain the same).
This is used to calculate polar angle with two dimensional points (z=constant).
begin | First point. |
center | Centre point. |
Definition at line 55 of file point.c.
Calculate distance between points
begin | First point |
end | Second point |
Resample image to cubic image volume, where all three dimensions are the same, with cubic voxel sizes. Note that some smoothing occurs in the process, therefore the use of this function should be limited to illustrations of image data.
img1 | Pointer to IMG to be resliced; this image is not modified. |
dim | New dimension; enter 0 to use the largest dimension in image. |
img2 | Pointer to initiated IMG where resliced data will be stored. |
Definition at line 16 of file imgtransform.c.
|
extern |
Replace IMG data values by their absolute values.
img | Pointer to IMG data. |
Definition at line 292 of file imgarithm.c.
Simple arithmetics between matching IMG planes and frames. Specify the operation as one of characters +, -, /, :, *, ., x. Results that are higher than ulimit are set to ulimit.
img1 | The first IMG data. |
img2 | The second IMG data. |
operation | Operation, one of the characters +, -, /, :, *, ., x. |
ulimit | Results that are higher than ulimit are set to ulimit; set to <=0 if not needed. |
verbose | Verbose level; if <=0, then nothing is printed into stderr. |
Definition at line 16 of file imgarithm.c.
|
extern |
Simple arithmetic between IMG and specified constant.
Specify the operation as one of characters +, -, /, :, *, ., x. Results that are higher than ulimit are set to ulimit.
img | IMG data which is modified. |
operand | Constant value which is used to modify the data. |
operation | Operation, one of the characters +, -, /, :, *, ., x. |
ulimit | Results that are higher than ulimit are set to ulimit; set to <=0 if not needed. |
verbose | Verbose level; if <=0, then nothing is printed into stderr. |
Definition at line 100 of file imgarithm.c.
Referenced by imgConvertUnit(), and imgTimeIntegral().
Simple arithmetic between matching IMG planes and the first frame of img2.
Specify the operation as one of characters +, -, /, :, *, ., x. Results that are higher than ulimit are set to ulimit.
img1 | IMG data which is modified. |
img2 | Operand IMG data, only the first frame is used. |
operation | Operation, one of the characters +, -, /, :, *, ., x. |
ulimit | Results that are higher than ulimit are set to ulimit; set to <=0 if not needed. |
verbose | Verbose level; if <=0, then nothing is printed into stderr. |
Definition at line 168 of file imgarithm.c.
Calculate (incomplete) area under moment curve (AUMC) for every pixel in a dynamic image.
Data is not extrapolated. Frame gaps or overlaps are not accepted.
img | Pointer to dynamic image; not modified. Frame times are obligatory. |
oimg | Pointer to empty IMG struct in which the AUMC will be written; any old contents are deleted. |
verbose | Verbose level; if zero, then nothing is printed to stderr or stdout. |
Definition at line 540 of file imgarithm.c.
|
extern |
Calculates the Area-Under-Curve of an average time-activity curve of all pixels or bins in the specified IMG data.
img | (Dynamic) IMG data. |
avgauc | Pointer to a float were the average TAC AUC will be written. |
Definition at line 91 of file imgeval.c.
Calculates an average time-activity curve of pixels or bins in the specified IMG data.
Mask image specifies the pixels that are included in the average. If all pixels are to be averaged, then NULL can be given instead of mask image.
img | (Dynamic) IMG data from which cluster TAC is computed. |
timg | Mask: 0=excluded, otherwise included. Enter NULL to include all pixels in the average. |
tac | Allocated float array for the TAC. |
Definition at line 34 of file imgeval.c.
Referenced by imgAverageTAC().
|
extern |
Calculates an average time-activity curve of all pixels or bins in the specified IMG data.
img | (Dynamic) IMG data from which TAC is computed. |
tac | Allocated float array for the TAC. |
Definition at line 15 of file imgeval.c.
Referenced by imgNoiseTemplate(), and sifAllocateWithIMG().
|
extern |
Converts the unit of pixel values in IMG based to specified unit string.
img | Pointer to IMG struct. |
unit | String containing the new unit. |
Definition at line 480 of file imgarithm.c.
|
extern |
Pixel values that exceed or go under a user-defined limit are set to that limit value.
image | Pointer to IMG struct which will be filtered here. |
cutoff | Cut-off value. |
mode | Mode of operation: 0=pixels exceeding the limit are cut off, 1=pixels which go under the limit are cut off. |
Definition at line 306 of file imgthreshold.c.
|
extern |
Correct frame times if frames are slightly overlapping or have small gaps in between. Large gap is not corrected and it does not lead to an error.
img | Pointer to IMG struct containing the 4D image data. |
Definition at line 77 of file imgframe.c.
Referenced by imgReadModelingData().
|
extern |
Correct frame times so that frames are not overlapping.
img | Pointer to IMG struct containing the 4D image data. |
Definition at line 109 of file imgframe.c.
|
extern |
Flip IMG data like viewed from above.
img | Pointer to IMG which will be flipped. |
Definition at line 115 of file imgflips.c.
|
extern |
Flip IMG data horizontally (left-right).
Definition at line 13 of file imgflips.c.
|
extern |
Flip IMG data planes (head-toes).
To work properly, the plane numbers must be contiguous.
Definition at line 55 of file imgflips.c.
Referenced by imgAnalyzeToEcat().
|
extern |
Flip IMG data like viewed from right side.
img | Pointer to IMG which will be flipped |
Definition at line 73 of file imgflips.c.
|
extern |
Flip IMG data vertically (up-down).
Definition at line 34 of file imgflips.c.
|
extern |
Fill gaps between time frames by extending adjacent frames over the gap. Overlaps, and gap before the first frame is ignored.
img | Pointer to IMG struct containing the 4D image data. |
verbose | Verbose level; if zero, then nothing is printed to stderr or stdout. |
Definition at line 50 of file imgframe.c.
Integration from first frame (0..last) to last frame (first..dimt) to iimg, which is allocated here.
Frames do not have to be continuous in time. Time unit in integral is sec. Raw data (sinogram) must be divided by frame durations before calling this. If dynamic image data does not contain frame times (e.g. Analyze image) then just the sum is calculated.
img | (Dynamic) IMG data. |
first | First frame to include in AUC; 0..dimt-1. |
last | Last frame to include in AUC; 0..dimt-1. |
iimg | Pointer to initiated and empty AUC IMG data. |
verbose | Verbose level; if <=0, then nothing is printed into stderr. |
Definition at line 346 of file imgarithm.c.
Referenced by imgsegmSimilar(), imgThresholding(), imgThresholdingLowHigh(), and imgTimeIntegral().
|
extern |
Check for gaps or overlap between frame times. Gap before the first frame is ignored.
img | Pointer to IMG struct containing the 4D image data. Data is not modified. |
verbose | Verbose level; if zero, then nothing is printed to stderr or stdout. |
Definition at line 15 of file imgframe.c.
|
extern |
Alvarez-Mazorra approximate Gaussian image filtering in 1-3 dimensions.
References:
img | Image data to be processed; data is overwritten with filtered image. All image frames are processed. |
xsd | Gaussian S.D. in pixels in x dimension; SD=FWHM/2.355. Enter 0 to not filter in x dimension. |
ysd | Gaussian S.D. in pixels in y dimension; SD=FWHM/2.355. Enter 0 to not filter in y dimension. |
zsd | Gaussian S.D. in pixels in z dimension; SD=FWHM/2.355. Enter 0 to not filter in z dimension. |
passNr | Number of filtering passes, usually 4 or more; enter 0 to use the default steps (4). |
tolerance | Tolerance; enter 0.0 to use the default (1.0E-06). |
verbose | Verbose level; if zero, then only warnings are printed into stderr. |
Definition at line 173 of file imgfilter.c.
|
extern |
Gaussian extended box image filtering in 1-3 dimensions.
References:
img | Image data to be processed; data is overwritten with filtered image. All image frames are processed. |
xsd | Gaussian S.D. in pixels in x dimension; SD=FWHM/2.355. Enter 0 to not filter in x dimension. |
ysd | Gaussian S.D. in pixels in y dimension; SD=FWHM/2.355. Enter 0 to not filter in y dimension. |
zsd | Gaussian S.D. in pixels in z dimension; SD=FWHM/2.355. Enter 0 to not filter in z dimension. |
passNr | Number of filtering passes, usually 3-5; enter 0 to use the default steps (4). |
verbose | Verbose level; if zero, then only warnings are printed into stderr. |
Definition at line 408 of file imgfilter.c.
|
extern |
Gaussian finite impulse response (FIR) isotropic or anisotropic image filtering in 1-3 dimensions.
Based on the code in: Getreuer P. A survey of Gaussian convolution algorithms. Image Processing On Line 2013;3:286–310. https://doi.org/10.5201/ipol.2013.87
img | Image data to be processed; data is overwritten with filtered image. All image frames are processed. |
xsd | Gaussian S.D. in pixels in x dimension; SD=FWHM/2.355. Enter 0 to not filter in x dimension. |
ysd | Gaussian S.D. in pixels in y dimension; SD=FWHM/2.355. Enter 0 to not filter in y dimension. |
zsd | Gaussian S.D. in pixels in z dimension; SD=FWHM/2.355. Enter 0 to not filter in z dimension. |
tolerance | Tolerance; enter 0.0 to use the default (1.0E-03). |
verbose | Verbose level; if zero, then only warnings are printed into stderr. |
Definition at line 18 of file imgfilter.c.
Referenced by imgPVCRRL(), and imgPVCRVC().
Compute sum absolute difference and/or sum absolute average between consecutive frames.
img | Dynamic image; not modified. |
dimg | Pointer to an empty IMG struct in which the sum of absolute differences will be written; any old contents are deleted; NULL, if not needed. |
mimg | Pointer to an empty IMG struct in which the sum of absolute means will be written; any old contents are deleted; NULL, if not needed. |
verbose | Verbose level; if zero, then nothing is printed to stderr or stdout. |
Definition at line 180 of file imgframe.c.
Compute the number of increases and decreases between consecutive frames.
img | Dynamic image; not modified. |
iimg | Pointer to an empty IMG struct in which the nr of increases will be written; any old contents are deleted; NULL, if not needed. |
dimg | Pointer to an empty IMG struct in which the nr of decreases will be written; any old contents are deleted; NULL, if not needed. |
verbose | Verbose level; if zero, then nothing is printed to stderr or stdout. |
Definition at line 249 of file imgframe.c.
|
extern |
Replace IMG data values by their inverse value (1/activity).
Pixels with <=0 are set to zero.
img | Pointer to IMG data. |
Definition at line 314 of file imgarithm.c.
|
extern |
Replace IMG data values by their natural logarithms.
img | Pointer to IMG data. |
Definition at line 248 of file imgarithm.c.
|
extern |
Replace IMG data values by their log10 values.
img | Pointer to IMG data. |
Definition at line 270 of file imgarithm.c.
|
extern |
Cloak mask.
img | Pointer to 2D/3D mask image. |
dim | Cloak the existing mask in xy (2) or xyz (3) dimensions. |
id | Id number for the cloak mask. Should be different from existing IDs. |
Definition at line 429 of file mask.c.
Conjunction (AND, wedge) for two 3D mask images.
mask1 | Pointer to IMG structure containing the first mask image; will be overwritten by the conjunction mask. |
mask2 | Pointer to IMG structure containing the second mask image; not modified. |
|
extern |
Count the nr of positive values inside 3D mask image.
img | Pointer to mask IMG structure. |
Dilate the 3D mask image.
img | Pointer to IMG structure containing the mask image. |
se | Pointer to IMG structure containing the structuring element; all dimensions must be odd numbers. |
Definition at line 80 of file mask.c.
Erode the 3D mask image.
img | Pointer to IMG structure containing the mask image. |
se | Pointer to IMG structure containing the structuring element; all dimensions must be odd numbers. |
Definition at line 34 of file mask.c.
|
extern |
Flood filling for the Region labelling.
Processes only the first frame, even if several do exist.
Based on Burger W and Burge MJ: Principles of Digital Image Processing - Core Algorithms, Springer, 2009, DOI 10.1007/978-1-84800-195-4.
m | Pointer to IMG structure containing the mask image to be flood filled. Pixels with value 1 are flood filled with label, pixels with value <1 are considered as background, and pixels with values >1 are considered to belong to another already labelled region. |
sz | Z coordinate of the starting point [0..dimz-1]. |
sy | Y coordinate of the starting point [0..dimy-1]. |
sx | X coordinate of the starting point [0..dimx-1]. |
label | The label to be assigned to the region; at least 2. |
n | The number of pixels that got labelled; enter NULL, if not needed. |
verbose | Verbose level; if zero, then nothing is printed into stdout or stderr. |
Definition at line 352 of file mask.c.
Referenced by imgMaskRegionLabeling().
|
extern |
Invert the 3D mask image, setting zeroes to ones, and non-zeroes to zeroes.
Processes only the first frame, even if several do exist.
img | Pointer to mask IMG structure. |
Region labelling with flood filling.
Processes only the first frame, even if several do exist.
Based on Burger W and Burge MJ: Principles of Digital Image Processing - Core Algorithms, Springer, 2009, DOI 10.1007/978-1-84800-195-4.
mask1 | Pointer to IMG structure containing the mask image to be region labelled; not modified. All pixels with value < 0.1 are considered to belong to background, others to foreground. |
mask2 | Pointer to an empty but initiated IMG structure for the output, the region labelled mask image. |
n | The number of regions that were found; enter NULL, if not needed. |
verbose | Verbose level; if zero, then nothing is printed into stdout or stderr |
Definition at line 279 of file mask.c.
|
extern |
Get the list of ROIs in the mask image.
img | Pointer to mask image. Pixel values <=0 represent pixels outside any ROI, and each rounded positive integer value represents one ROI. |
list | Initiated list of integers. |
Definition at line 176 of file imgeval.c.
Calculate TAC as weighted average of voxels in specified image data with relative weights given in a mask image.
img | Pointer to allocated image from which the weighted TAC is calculated. |
mask | Pointer to mask image; x, y, and z dimensions must be the same as in the image to which the mask is applied. |
tac | Pointer to an array where weighted pixel averages are written; it must be allocated for size >= dimt. |
verbose | Verbose level; set to <=0 to prevent all prints to stdout. |
Definition at line 126 of file imgeval.c.
|
extern |
Image mean filtering in 1-4 dimensions.
img | Image data to be processed; data is overwritten with filtered image. All image frames are processed. |
xn | Number of adjacent pixels in x dimension; Enter 0 to not filter in x dimension. |
yn | Number of adjacent pixels in y dimension; Enter 0 to not filter in y dimension. |
zn | Number of adjacent pixels in z dimension; Enter 0 to not filter in z dimension. |
tn | Number of adjacent pixels in t dimension; Enter 0 to not filter in t dimension. |
verbose | Verbose level; if zero, then only warnings are printed into stderr. |
Definition at line 624 of file imgfilter.c.
Calculate image average over z dimension (image planes).
img1 | Pointer to input IMG data structure; not modified. |
img2 | Pointer to output IMG data structure; allocated here. |
Definition at line 157 of file imgflips.c.
Calculate (incomplete) mean residence time (MRT) for every pixel in dynamic image.
MRT = area under moment curve (AUMC) / area under curve (AUC). Data is not extrapolated. Frame gaps or overlaps are not accepted.
img | Pointer to dynamic image; not modified. Frame times are obligatory. |
oimg | Pointer to empty IMG struct in which the AUMC will be written; any old contents are deleted. |
verbose | Verbose level; if zero, then nothing is printed to stderr or stdout. |
Definition at line 606 of file imgarithm.c.
|
extern |
Filter out pixels that are over limit x higher than their closest 8 neighbour pixels.
img | Pointer to IMG struct which will be filtered here. |
limit | Cut-off value. |
Definition at line 339 of file imgthreshold.c.
|
extern |
Divide or multiply raw data (sinogram) counts by frame duration.
If IMG is not raw data, division is quietly not done. Error is returned if sinogram does not contain frame times, except if sinogram contains only one time frame, also then division is not done.
img | IMG containing raw data. |
operation | 1=division, 0=multiply. |
Definition at line 442 of file imgarithm.c.
|
extern |
Seeded region growing based on thresholds.
Calls itself recursively until neighbouring pixels fall outside thresholds. Because of recursion, program which uses this function needs a large space for stack.
img | Pointer to static image data, to which the threshold is applied. |
sz | Seed pixel position [z,y,x] as indices. |
sy | Seed pixel position [z,y,x] as indices. |
sx | Seed pixel position [z,y,x] as indices. |
lthr | Lower threshold as absolute value. |
uthr | Upper threshold as absolute value. |
mask | Pointer to mask image; must have the same dimensions as the static image. |
verbose | Verbose level; if zero, then only warnings are printed into stderr. |
Definition at line 394 of file imgthreshold.c.
Referenced by imgRegionGrowingByThreshold().
Image size scaling using the defined method.
src | Source image to be scaled. |
targ | Scaled image; must be allocated to the size of resulting image. |
zoom | Scaling factor (integer); currently must be >=1. |
method | Method code number (not used yet). |
Definition at line 123 of file imgtransform.c.
|
extern |
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().
|
extern |
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.
|
extern |
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.
|
extern |
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.
|
extern |
|
extern |
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.
|
extern |
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.
|
extern |
Sets scanner specific parameters in IMG data. If possible, set image zoom before calling this.
img | IMG data which is filled with scanner specific information |
scanner_type | SCANNER_ECAT931, SCANNER_ADVANCE, SCANNER_HRPLUS, SCANNER_HRRT, SCANNER_STEVCT_PET, as defined in libtpcimgio.h |
Definition at line 14 of file imgscanner.c.
Referenced by imgAnalyzeToEcat(), and imgNiftiToEcat().
Shrink the image data matrix into half of the original size in each dimension.
Eight neighbouring pixels are averaged into one pixel, without any interpolation etc.
img1 | Pointer to the original image; not changed. |
img2 | Pointer to the shrunken image; must be initiated. If allocated for correct size, then only pixel values are set; if not, then any previous contents are deleted, memory is allocated, header information is set, and of course the pixel values are set. |
doz | Shrink (1) the image in z dimension (over image planes), or shrink only in x and y dimensions (0). |
Definition at line 263 of file imgtransform.c.
|
extern |
Smooth dynamic image data over specified number of time frames.
Average is weighted by frame durations. Gaps or overlaps in frame times are not taken into account. Do not use this for quantitative analysis, but only for robust peak search etc.
img | Pointer to IMG structure containing the 4D image data. |
n | Nr of frames to average; n must be an odd number and at least 3. |
Definition at line 136 of file imgframe.c.
|
extern |
Make 3D structuring element for eroding and dilation.
img | Pointer to empty IMG struct for the element. |
structuring_element | Structuring element:
|
verbose | Verbose level; if zero, then only warnings are printed into stderr |
Definition at line 126 of file mask.c.
Inflate the image data matrix into twice the original size in each dimension.
Each pixel is inflated into eight pixels, without any interpolation etc.
img1 | Pointer to the original image; not changed. |
img2 | Pointer to the swollen image; must be initiated. If allocated for correct size, then only pixel values are set; if not, then any previous contents are deleted, memory is allocated, header information is set, and of course the pixel values are set. |
doz | Inflate (1) the image in z dimension (over image planes), or only in x,y dimensions (0). |
Definition at line 202 of file imgtransform.c.
Threshold IMG by a mask image (template).
Sets pixel values in img to thrValue, if corresponding pixel value in template is == 0. Only first frame of template is used.
img | Image to threshold. |
templt | Threshold template (mask image with 1 frame) where 0=cut off. |
thrValue | Value which is written in cut off pixels. |
Definition at line 282 of file imgthreshold.c.
|
extern |
Threshold dynamic or static IMG data.
Pixel time-activity curves (TACs) which have AUC less than Threshold*Max_AUC will be set to zero.
img | IMG data. |
threshold_level | Threshold level, e.g. 0.50 will set to zero all pixels that are less than 50% of maximum pixel. |
thr_nr | Number of pixels that will fall below the threshold level; give NULL pointer, if not needed. |
Definition at line 19 of file imgthreshold.c.
|
extern |
Threshold dynamic or static IMG data.
Checks whether pixel AUCs are lower or higher than the specified threshold levels * Max_AUC. Those pixel TACs are set to zero, or alternatively, if mask IMG is given, corresponding mask image pixel is set to 0.
img | (Dynamic) IMG data. |
lower_threshold_level | Lower threshold level, e.g. 0.10 will set to zero all pixels that are less than 10% of maximum pixel |
upper_threshold_level | Upper threshold level, e.g. 0.90 will set to zero all pixels that are over 90% of maximum pixel |
timg | Mask image; if empty, then it will be allocated here; if pre-allocated, then mask image value changed to 0 when necessary, but 0 is never changed to 1; enter NULL, if original TACs are to be thresholded to zeroes |
lower_thr_nr | Number of pixels that will fall below the lower threshold level; give NULL pointer, if not needed. |
upper_thr_nr | Number of pixels rejected because above the upper threshold level; give NULL pointer, if not needed. |
Definition at line 79 of file imgthreshold.c.
Creates a mask (template) image based on lower and upper threshold values.
This function allocates memory for the mask image. If pixel value in original image is >=minValue and <=maxValue, the corresponding mask pixel is set to 1, otherwise to 0. Only the first frame of images are used.
img | Original image; only first frame is used here. |
minValue | Lower threshold. |
maxValue | Upper threshold. |
timg | Mask image; if empty, then it will be allocated here; if pre-allocated, then mask pixel value changed to 0 when necessary, but 0 is never changed to 1. |
Definition at line 257 of file imgthreshold.c.
|
extern |
Creates a mask (template) image based on lower and upper threshold values.
This function allocates memory for the mask image. If pixel value in original image is >=minValue and <=maxValue, the corresponding mask pixel is set to 1, otherwise to 0. Only the first frame of images are used.
img | Original image; only first frame is used here. |
minValue | Lower threshold. |
maxValue | Upper threshold. |
timg | Mask image; if empty, then it will be allocated here; if pre-allocated, then template value changed to 0 when necessary, but 0 is never changed to 1. |
count | The number of pixels that pass the threshold limits is written here; set to NULL if not needed. |
Definition at line 191 of file imgthreshold.c.
Referenced by imgMaskRegionLabeling(), and imgThresholdMask().
Calculate TAC as average of voxels in image data, including only voxels which have specified value in the mask image.
img | Pointer to allocated image from which the mean TAC is calculated. |
mask | Pointer to mask image; x, y, and z dimensions must be the same as in the image to which the mask is applied. |
mv | Voxels with this value in mask image are included in the average. |
tac | Pointer to an array where weighted pixel averages are written; it must be allocated for size >= dimt. |
verbose | Verbose level; set to <=0 to prevent all prints to stdout. |
Definition at line 214 of file imgeval.c.
|
extern |
Magnify one frame of dynamic 2D image by integer zoom factor. Pixel values are simply duplicated.
frame | Index of the frame to be scaled. |
src | Source data in dynamic 2D array: srcp[y][x][frame]. |
targ | Pre-allocated target static 2D data matrix: targ[y][x]; actual matrix size is allowed to be larger than what is used here. |
width | Width (x dim) of the source data matrix. |
height | Height (y dim) of the source data matrix. |
zoom | Zoom factor. If less than 2, then matrix is just copied. |
Definition at line 159 of file imgtransform.c.
Referenced by imgScale().
|
extern |
|
extern |
Write one frame or plane in IMG data as a TIFF 6.0 format image. Overwrites existing TIFF file.
img | IMG containing PET image/sinogram data. |
plane | matrix index of plane (0..dimz-1); all if <0. |
frame | matrix index of frame (0..dimt-1); all if <0. |
maxvalue | colours are scaled between 0 and maxvalue; if <=0, then searches max and sets maxvalue. |
colorscale | PET_GRAYSCALE, PET_GRAYSCALE_INV or PET_RAINBOW. |
fname | name of output TIFF file. |
matXdim | Nr of matrices tiled horizontally; enter 0 for automatic calculation. |
matYdim | Nr of matrices tiled vertically; enter 0 for automatic calculation. |
verbose | Verbose level; if zero, then nothing is printed to stderr or stdout. |
status | Pointer to a string (allocated for at least 64 chars) where error message or other execution status will be written; enter NULL, if not needed. |
Definition at line 15 of file imgtiff.c.