35 unsigned long i, j, n, nvox = 0;
39 cout <<
"Filling a range:" << endl;
40 cout <<
"Range: " << min <<
" - " << max << endl;
41 cout <<
"Fill value: " << fill << endl << endl;
43 cout <<
"Filling a range" << endl << endl;
45 for ( n=0; n<p->
images(); n++ ) {
47 for ( i=n*imgsize, j=i+imgsize; i<j; i++ ) if ( (*p)[i] >= min && (*p)[i] <= max ) {
54 cout <<
"Number of voxels changed: " << nvox << endl;
73 unsigned long i, j, n, x, y, z;
78 cout <<
"Correcting the image linear gradient:" << endl;
79 cout <<
"Image\tb0\tb1\tb2\tb3" << endl;
81 cout <<
"Correcting the image linear gradient" << endl << endl;
85 for ( z=0; z<p->
sizeZ(); z++ ) {
86 for ( y=0; y<p->
sizeY(); y++ ) {
87 for ( x=0; x<p->
sizeX(); x++ ) {
101 for ( i=1; i<4; i++ ) {
102 for ( j=0; j<i; j++ )
104 if ( a[i][i] < 1 ) a[i][i] = 1;
107 for ( n=0; n<p->
images(); n++ ) {
108 for ( i=0; i<4; i++ ) b[i] = 0;
111 for ( y=0; y<p->
sizeY(); y++ ) {
112 for ( x=0; x<p->
sizeX(); x++, i++ ) {
123 cout << n <<
tab << b[0] <<
tab << b[1] <<
tab << b[2] <<
tab << b[3] << endl;
125 for ( y=0; y<p->
sizeY(); y++ ) {
126 for ( x=0; x<p->
sizeX(); x++, i++ ) {
127 v = (*p)[i] - b[0] + b[1]*x + b[2]*y + b[3]*z;
155 unsigned long i, j, k, n, x, y, z, c;
161 for ( i=0; i<4; i++ ) center = center + tet[i];
164 normal[0] = tet[0].
normal(tet[1], tet[2]);
165 normal[1] = tet[1].
normal(tet[2], tet[3]);
166 normal[2] = tet[2].
normal(tet[3], tet[0]);
167 normal[3] = tet[3].
normal(tet[0], tet[1]);
171 for ( i=0; i<4; i++ ) {
172 origin[i] = normal[i].
scalar(tet[i]);
173 if ( normal[i].scalar(center) < origin[i] ) {
174 normal[i] = -normal[i];
175 origin[i] = -origin[i];
180 cout <<
"Extracting a tetrahedron:" << endl;
181 cout <<
"Vertices: " << tet[0] << endl;
182 cout <<
" " << tet[1] << endl;
183 cout <<
" " << tet[2] << endl;
184 cout <<
" " << tet[3] << endl;
185 cout <<
"Center: " << center << endl;
186 cout <<
"Normals: " << normal[0] <<
" (" << origin[0] <<
")" << endl;
187 cout <<
" " << normal[1] <<
" (" << origin[1] <<
")" << endl;
188 cout <<
" " << normal[2] <<
" (" << origin[2] <<
")" << endl;
189 cout <<
" " << normal[3] <<
" (" << origin[3] <<
")" << endl;
192 cout <<
"Extracting a tetrahedron" << endl << endl;
194 for ( i=n=0; n<p->
images(); n++ ) {
196 for ( z=0; z<p->
sizeZ(); z++ ) {
197 for ( y=0; y<p->
sizeY(); y++ ) {
198 for ( x=0; x<p->
sizeX(); x++, i++ ) {
199 for ( j=0; j<4; j++ ) {
200 if ( normal[j].x()*x + normal[j].
y()*y + normal[j].
z()*z < origin[j] )
void change_type(char letter)
Get the data type indicated by a single letter code.
Header file for general utilities.
Class for complex numbers.
Generalized matrix class.
double average(size_t cc, double xf, double yf, double zf, size_t nn, double iscale)
Averages in the xy plane when scaling is less than 1.
General image parameter class.
int img_delete_range(Bimage *p, double min, double max, double fill, int fill_type)
Replaces values in a given range with the fill value.
double LU_decomposition()
Matrix inversion by LU decomposition.
Vector3 normal(Vector3 &v1, Vector3 &v2)
double scalar(const Vector3 &v) const
void set(size_t j, double v)
Sets a single value at the given index.
Header file for functions for editing image contents.
Header file for matrix functions.
int img_gradient_correction(Bimage *p)
Calculates and corrects for a linear gradient across an image.
int img_extract_tetrahedron(Bimage *p, Vector3< float > *tet, double fill, int fill_type)
Extracts a tetrahedral part of the image.
ostream & tab(ostream &out)