My Project
Functions | Variables
img.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include "studynr.h"
#include "halflife.h"
#include "include/imgunit.h"
#include "include/img.h"
Include dependency graph for img.c:

Go to the source code of this file.

Functions

void imgInit (IMG *image)
 
void imgEmpty (IMG *image)
 
int imgAllocate (IMG *image, int planes, int rows, int columns, int frames)
 
int imgAllocateWithHeader (IMG *image, int planes, int rows, int columns, int frames, IMG *image_from)
 
char * imgStatus (int status_index)
 
void imgSetStatus (IMG *img, int status_index)
 
void imgInfo (IMG *image)
 
int imgCopyhdr (IMG *image1, IMG *image2)
 
int imgExtractRange (IMG *img1, IMG_RANGE r, IMG *img2)
 

Variables

static const char * imgmsg []
 

Function Documentation

◆ imgAllocate()

int imgAllocate ( IMG image,
int  planes,
int  rows,
int  columns,
int  frames 
)

Allocates memory for img data. Old contents are not saved.

Parameters
imageinitialized image
planesnumber of allcoated planes
rowsnumber of allocated rows
columnsnumber of allocated columns
framesnumber of allocated frames
Returns
0 if ok, 1 image is not initialized, 2 invalid input dimension(s), 3 failed to allocate header, 4 - 8 failed to allocate image data

Definition at line 285 of file img.c.

References IMG::_col, IMG::_header, IMG::_pln, IMG::_pxl, IMG::_row, IMG::column, IMG::decayCorrFactor, IMG::dimt, IMG::dimx, IMG::dimy, IMG::dimz, IMG::end, IMG_STATUS_OCCUPIED, IMG_STATUS_UNINITIALIZED, IMG_TEST, imgEmpty(), imgSetStatus(), IMG::m, IMG::mid, IMG::pixel, IMG::plane, IMG::planeNumber, IMG::prompts, IMG::randoms, IMG::row, IMG::sd, IMG::start, IMG::status, STATUS_FAULT, STATUS_NOMEMORY, STATUS_OK, and IMG::weight.

Referenced by ecat63ReadAllToImg(), ecat63ReadPlaneToImg(), imgAllocateWithHeader(), imgExtractRange(), imgMicropetCTToEcat7(), imgMicropetPETToEcat7(), imgReadAnalyze(), imgReadAnalyzeFirstFrame(), imgReadEcat63FirstFrame(), imgReadEcat7(), imgReadEcat7FirstFrame(), imgReadFrame(), test_create_img(), and test_create_polarmap().

Here is the call graph for this function:

◆ imgAllocateWithHeader()

int imgAllocateWithHeader ( IMG image,
int  planes,
int  rows,
int  columns,
int  frames,
IMG image_from 
)

This functions just combines imgAllocate() and imgCopyhdr().

Returns
Returns 0 if successful, otherwise returns <>0.
Parameters
imagePointer to IMG struct which will be allocated here
planesImage matrix dimensions; z
rowsImage matrix dimensions; y
columnsImage matrix dimensions; x
framesImage matrix dimensions; t
image_fromPointer to IMG struct where header contents will be copied from

Definition at line 357 of file img.c.

References imgAllocate(), and imgCopyhdr().

Here is the call graph for this function:

◆ imgCopyhdr()

int imgCopyhdr ( IMG image1,
IMG image2 
)

Copies the header fields from one image struct to another. Does not copy memory addresses or IMG sizes. Frame times, decay correction factors etc are copied, when possible. Plane numbers are copied, when possible.

Parameters
image1Pointer to input IMG data
image2Pointer to output IMG data
Returns
0 if successful, 1 invalid input, 2 poiters are to same image

Definition at line 501 of file img.c.

References IMG::_dataType, IMG::_fileFormat, IMG::axialFOV, IMG::decayCorrected, IMG::decayCorrFactor, IMG::dimt, IMG::dimz, IMG::end, IMG::gapx, IMG::gapy, IMG::gapz, IMG_TEST, IMG::isotopeHalflife, IMG::isWeight, MAX_POLARMAP_NUM_RINGS, IMG::mid, IMG::orientation, IMG::patientID, IMG::patientName, IMG::planeNumber, IMG::polarmap_num_rings, IMG::polarmap_ring_angle, IMG::polarmap_ring_position, IMG::polarmap_sectors_per_ring, IMG::polarmap_start_angle, IMG::prompts, IMG::radiopharmaceutical, IMG::randoms, IMG::resolutionx, IMG::resolutiony, IMG::resolutionz, IMG::sampleDistance, IMG::scanner, IMG::scanStart, IMG::sd, IMG::sizex, IMG::sizey, IMG::sizez, IMG::start, IMG::studyDescription, IMG::studyNr, IMG::transaxialFOV, IMG::type, IMG::unit, IMG::userProcessCode, IMG::weight, and IMG::zoom.

Referenced by imgAllocateWithHeader(), and imgExtractRange().

◆ imgEmpty()

void imgEmpty ( IMG image)

◆ imgExtractRange()

int imgExtractRange ( IMG img1,
IMG_RANGE  r,
IMG img2 
)

Extract a smaller 4D image from inside an IMG. Any existing data is overwritten.

Parameters
img1source image structure, 'occupied' (has allocated data)
rimage range structure
img2target image structure 'initialized' (has not allocated data)
Returns
0 if ok, 1 invalid input, 2 failed to allocate memory for target image

Definition at line 570 of file img.c.

References IMG::decayCorrFactor, IMG::dimt, IMG::dimx, IMG::dimy, IMG::dimz, IMG::end, IMG_RANGE::f1, IMG_RANGE::f2, IMG_STATUS_OCCUPIED, IMG_STATUS_UNINITIALIZED, IMG_TEST, imgAllocate(), imgCopyhdr(), imgEmpty(), imgSetStatus(), IMG::m, IMG::mid, IMG::planeNumber, IMG::prompts, IMG::randoms, IMG::sd, IMG::start, IMG::status, STATUS_FAULT, STATUS_NOMEMORY, STATUS_OK, IMG::weight, IMG_RANGE::x1, IMG_RANGE::x2, IMG_RANGE::y1, IMG_RANGE::y2, IMG_RANGE::z1, and IMG_RANGE::z2.

Here is the call graph for this function:

◆ imgInfo()

void imgInfo ( IMG image)

◆ imgInit()

void imgInit ( IMG image)

◆ imgSetStatus()

void imgSetStatus ( IMG img,
int  status_index 
)

◆ imgStatus()

char* imgStatus ( int  status_index)

Return pointer to string describing the image error status message

Parameters
status_indexindex of img_status_string
Returns
pointer to string

Definition at line 384 of file img.c.

References imgmsg, and STATUS_FAULT.

Referenced by imgRead().

Variable Documentation

◆ imgmsg

const char* imgmsg[]
static

Status (error) messages from image processing; see enum img_status_msg

Definition at line 113 of file img.c.

Referenced by imgSetStatus(), and imgStatus().