TPCCLIB
Loading...
Searching...
No Matches
flat2img.c File Reference

Construct an ECAT PET file from binary flat file. More...

Go to the source code of this file.

Functions

void zero_hot_spots (float *fdata, int dim)
int readMatrixInformation (char *fname, int *planeNr, int *frameNr, int *dim1, int *dim2)

Detailed Description

Construct an ECAT PET file from binary flat file.

Application name was previously flo2ecat.

Author
Vesa Oikonen

Definition in file flat2img.c.

Function Documentation

◆ readMatrixInformation()

int readMatrixInformation ( char * fname,
int * planeNr,
int * frameNr,
int * dim1,
int * dim2 )

Read ASCII file containing information on matrix dimensions

Returns
Returns 0 when successful, otherwise <> 0.
Parameters
fnameMatrix information filename
planeNrmatrix plane number (zdim)
frameNrmatrix time frame number (tdim)
dim1matrix column number (xdim)
dim2matrix row number (ydim)

Definition at line 468 of file flat2img.c.

479 {
480 FILE *fp;
481 int n;
482
483 if(fname==NULL || planeNr==NULL || frameNr==NULL || dim1==NULL || dim2==NULL)
484 return(1);
485 fp=fopen(fname, "r"); if(fp==NULL) return(2);
486 n=fscanf(fp, "%d %d %d %d", planeNr, frameNr, dim1, dim2);
487 fclose(fp); if(n!=4) return(3);
488 if(*planeNr<1 || *frameNr<1 || *dim1<1 || *dim2<1) return(4);
489 return(0);
490}

◆ zero_hot_spots()

void zero_hot_spots ( float * fdata,
int dim )

Calculate the distance between the pixel and the center of matrix. If the distance is greater than radius of FOV, pixel value is set to zero.

Parameters
fdataPointer to array containing one 2D image matrix
dimDimensions (x and y) of the image matrix

Definition at line 441 of file flat2img.c.

446 {
447 float *fptr;
448 float r, d;
449 int i;
450
451 r=(float)dim/2.0; if(r>25.0) r-=5.0;
452 fptr=fdata;
453 for(i=0; i<dim*dim; i++, fptr++ ) {
454 d=hypotf((float)(i/dim-dim/2), (float)(i-dim*(i/dim)-dim/2));
455/*
456 d=sqrt((i/dim-dim/2)*(i/dim-dim/2)+
457 (i-dim*(i/dim)-dim/2)*(i-dim*(i/dim)-dim/2));
458*/
459 if(d>r) *fptr=0.0;
460 }
461}