Skip to content

Commit

Permalink
- minor fixes to Image::Transform class and related Image::Interp cla…
Browse files Browse the repository at this point in the history
…sses

- don't bother checking for OpenGL extensions in configure script
- build script now adds folder '3rd_party' to search path if found (useful to store OpenGL-related 3rd-party code)
  • Loading branch information
jdtournier committed Aug 23, 2012
1 parent c5c1622 commit d0e582d
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 49 deletions.
5 changes: 5 additions & 0 deletions build
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ bin_dir = 'bin'
cmd_dir = 'cmd'
lib_dir = 'lib'
misc_dir = 'src'
other_dir = '3rd_party'
doc_dir = 'doc'
dev_dir = 'dev'

Expand All @@ -49,6 +50,8 @@ config_suffix = ''


include_paths = [ misc_dir, cmd_dir ]
if os.path.exists (other_dir):
include_paths += [ other_dir ]

# check if we are compiling a separate project:
mrtrix_dir = '.'
Expand All @@ -66,6 +69,8 @@ while os.path.abspath (os.path.dirname (get_real_name (build_script))) != os.pat
build_script = os.path.normpath (os.path.join (mrtrix_dir, get_real_name (build_script)))
mrtrix_dir = os.path.dirname (build_script)
include_paths += [ os.path.join (mrtrix_dir, misc_dir) ]
if os.path.exists (os.path.join (mrtrix_dir, other_dir)):
include_paths += [ os.path.join (mrtrix_dir, other_dir) ]
if verbose:
print ' ' + mrtrix_dir

Expand Down
31 changes: 0 additions & 31 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -810,44 +810,13 @@ use the MOC environment variable to specify the Qt4 moc command''')
#include <QGLWidget>
#include <iostream>
const char *extensions[] = {
"GL_ARB_fragment_shader",
"GL_ARB_vertex_shader",
"GL_ARB_geometry_shader4",
"GL_EXT_texture3D",
"GL_ARB_texture_float",
"GL_ARB_texture_non_power_of_two",
"GL_ARB_framebuffer_object",
NULL
};
class GLWidget : public QGLWidget {
public:
GLWidget (QWidget *parent = 0) : QGLWidget (parent) { }
~GLWidget() { }
protected:
void initializeGL () {
std::cout << glGetString (GL_VERSION) << "\\n";
size_t num = 0;
while (extensions[num]) ++num;
bool found[num];
for (size_t n = 0; n < num; ++n) found[n] = false;
std::string ext ((const char*) glGetString (GL_EXTENSIONS));
std::string::size_type start = 0, end;
do {
end = ext.find_first_of (" \\n\\t", start);
std::string e (ext.substr (start, end-start));
for (size_t n = 0; n < num; ++n)
if (e == extensions[n]) found[n] = true;
start = ext.find_first_not_of (" \\n\\t", end+1);
} while (start < std::string::npos);
std::cout << " OpenGL extensions:\\n";
for (size_t n = 0; n < num; ++n)
std::cout << " " << extensions[n] << ": " << ( found[n] ? "supported" : "*** NOT SUPPORTED! ***" ) << "\\n";
exit (0);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/image/interp/cubic.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ namespace MR
* \endcode
*/

template <class VoxelType> class Cubic : public VoxelType, Transform
template <class VoxelType> class Cubic : public VoxelType, public Transform
{
public:
typedef typename VoxelType::value_type value_type;
Expand Down
2 changes: 1 addition & 1 deletion lib/image/interp/linear.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ namespace MR
*/

template <class VoxelType>
class Linear : public VoxelType, Transform
class Linear : public VoxelType, public Transform
{
public:
typedef typename VoxelType::value_type value_type;
Expand Down
2 changes: 1 addition & 1 deletion lib/image/interp/nearest.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ namespace MR
*/

template <class VoxelType>
class Nearest : public VoxelType, Transform
class Nearest : public VoxelType, public Transform
{
public:
typedef typename VoxelType::value_type value_type;
Expand Down
2 changes: 1 addition & 1 deletion lib/image/interp/sinc.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ namespace MR
* \endcode
*/

template <class VoxelType> class Sinc : public VoxelType, Transform
template <class VoxelType> class Sinc : public VoxelType, public Transform
{
public:
typedef typename VoxelType::value_type value_type;
Expand Down
45 changes: 31 additions & 14 deletions lib/image/transform.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ namespace MR
bounds[0] = info.dim(0) - 0.5;
bounds[1] = info.dim(1) - 0.5;
bounds[2] = info.dim(2) - 0.5;
vox[0] = info.vox(0);
vox[1] = info.vox(1);
vox[2] = info.vox(2);
voxelsize[0] = info.vox(0);
voxelsize[1] = info.vox(1);
voxelsize[2] = info.vox(2);

set_matrix (V2S, info.transform());
for (size_t i = 0; i < 3; i++) {
Expand Down Expand Up @@ -90,11 +90,11 @@ namespace MR
}
//! Transform the position \p i from image-space to voxel-space \p v
template <class P1, class P2> void image2voxel (const P1& i, P2& v) const {
v[0] = i[0]/vox[0]; v[1] = i[1]/vox[1]; v[2] = i[2]/vox[2];
v[0] = i[0]/voxelsize[0]; v[1] = i[1]/voxelsize[1]; v[2] = i[2]/voxelsize[2];
}
//! Transform the position \p v from voxel-space to image-space \p i
template <class P1, class P2> void voxel2image (const P1& v, P2& i) const {
i[0] = v[0]*vox[0]; i[1] = v[1]*vox[1]; i[2] = v[2]*vox[2];
i[0] = v[0]*voxelsize[0]; i[1] = v[1]*voxelsize[1]; i[2] = v[2]*voxelsize[2];
}
//! Transform the position \p i from image-space to scanner-space \p s
template <class P1, class P2> void image2scanner (const P1& i, P2& s) const {
Expand Down Expand Up @@ -123,11 +123,11 @@ namespace MR
}
//! Transform the position \p r from image-space to voxel-space
template <class P1> Point<float> image2voxel (const P1& r) const {
return Point<float> (r[0]/vox[0], r[1]/vox[1], r[2]/vox[2]);
return Point<float> (r[0]/voxelsize[0], r[1]/voxelsize[1], r[2]/voxelsize[2]);
}
//! Transform the position \p r from voxel-space to image-space
template <class P1> Point<float> voxel2image (const P1& r) const {
return Point<float> (r[0]*vox[0], r[1]*vox[1], r[2]*vox[2]);
return Point<float> (r[0]*voxelsize[0], r[1]*voxelsize[1], r[2]*voxelsize[2]);
}
//! Transform the position \p r from image-space to scanner-space
template <class P1> Point<float> image2scanner (const P1& r) const {
Expand All @@ -146,6 +146,23 @@ namespace MR
return transform_vector (V2S, r);
}

const float* scanner2voxel_matrix () {
return *S2V;
}

const float* voxel2scanner_matrix () {
return *V2S;
}

const float* image2scanner_matrix () {
return *I2S;
}

const float* scanner2image_matrix () {
return *S2I;
}


void scanner2voxel_matrix (Math::Matrix<float>& M) {
get_matrix (M, S2V);
}
Expand All @@ -157,17 +174,17 @@ namespace MR
void voxel2image_matrix (Math::Matrix<float>& M) {
M.allocate (4,4);
M.identity();
M(0,0) = vox[0];
M(1,1) = vox[1];
M(2,2) = vox[2];
M(0,0) = voxelsize[0];
M(1,1) = voxelsize[1];
M(2,2) = voxelsize[2];
}

void image2voxel_matrix (Math::Matrix<float>& M) {
M.allocate (4,4);
M.identity();
M(0,0) = 1 / vox[0];
M(1,1) = 1 / vox[1];
M(2,2) = 1 / vox[2];
M(0,0) = 1 / voxelsize[0];
M(1,1) = 1 / voxelsize[1];
M(2,2) = 1 / voxelsize[2];
}

void image2scanner_matrix (Math::Matrix<float>& M) {
Expand Down Expand Up @@ -214,7 +231,7 @@ namespace MR
}

protected:
float S2V[3][4], V2S[3][4], I2S[3][4], S2I[3][4], vox[3];
float S2V[3][4], V2S[3][4], I2S[3][4], S2I[3][4], voxelsize[3];
float bounds[3];
bool out_of_bounds;

Expand Down

0 comments on commit d0e582d

Please sign in to comment.