Sometimes I have to put text on a path

Friday, July 25, 2008

matlab rigid registration between two images.

rigid registration is achieved by minimization of the sum of squared intensity differences (SSD) between two images.

Matlab routines

11/2005:

ftp://ftp.cea.fr/pub/dsv/madic/download/INRIAlign/INRIAlign2.zip
Author
Alexis Roche, (during his Phd, at the EPIDAURE Group, INRIA Sophia Antipolis). Alexis is now with the CEA SHFJ, anatomo-fonctional neuro-imaging unit, Orsay, France.
Some References
  • L. Freire, A. Roche and J.-Fr. Mangin. What is the best similarity measure for motion correction in fMRI? IEEE Transactions in Medical Imaging, p. 470-484, 2002.
  • L. Freire and J.-F. Mangin. Motion correction algorithms may create spurious brain activations in the absence of subject motion. Neuroimage 14(3), p. 709-722, september 2001.
  • P.J. Rousseeuw and A.M. Leroy. Robust Regression and Outlier Detection. Wiley Series in Probability and Mathematical Statistics. 1987.

The INRIAlign toolbox enhances the standard SPM realignment routine (see topic: spm_realign_ui in SPM99 documentation). In the latter, rigid registration is achieved by minimization of the sum of squared intensity differences (SSD) between two images. As noted by several SPM users, SSD based registration may be biased by a variety of image artifacts and also by activated areas. To get around this problem, INRIAlign reduces the influence of large intensity differences by weighting errors using a non-quadratic, slowly-increasing function (rho function). This is basically the principle of an M-estimator.

Thursday, July 24, 2008

mesh structure in meshlab

the mesh is stored in a object m of type MyMesh


Accessing the coords of all the vertexes


MyMesh::VertexIterator vi;
for(vi = m.vert.begin(); vi!=m.vert.end(); ++vi ) 
{
DoSomething((*vi).P()); 
}


Accessing all the faces and computing their barycenter


MyMesh::FaceIterator vi;
for(fi = m.face.begin(); vi!=m.face.end(); ++fi ) 
{
MyMesh::CoordType b = ((*fi).V(0)->P() + (*fi).V(1)->P() + (*fi).V(2)->P() ) / 3.0; 
}

or using a common shorthand for accessing to the coord of a face vertex:
MyMesh::FaceIterator vi;
for(fi = m.face.begin(); vi!=m.face.end(); ++fi ) 
{
MyMesh::CoordType b = ((*fi).P(0) + (*fi).P(1) + (*fi).P(2) ) / 3.0; 
}

Or even in a shorter way:
MyMesh::FaceIterator vi;
for(fi = m.face.begin(); vi!=m.face.end(); ++fi ) 
{
MyMesh::CoordType b = vcg::Barycenter(*fi); 
}

Creating the simplest single triangle mesh.
m.Clear();
Allocator<MyMesh>::AddVertices(m,3);
Allocator<MyMesh>::AddFaces(m,1);

MyMesh::VertexPointer ivp[3];
VertexIterator vi=in.vert.begin();
ivp[0]=&*vi;(*vi).P()=CoordType ( 1.0, 1.0, 1.0); ++vi;
ivp[1]=&*vi;(*vi).P()=CoordType (-1.0, 1.0,-1.0); ++vi;
ivp[2]=&*vi;(*vi).P()=CoordType (-1.0,-1.0, 1.0); ++vi;

FaceIterator fi=in.face.begin();
(*fi).V(0)=ivp[0];  (*fi).V(1)=ivp[1]; (*fi).V(2)=ivp[2];

look to complex/trimesh/create/platonic.hplatonic.h for more examples.


Destroying Elements


Lazy deletion strategy.

Note that the two basic deletion strategies are very low level functions. They simply mark as deleted the corresponding entries without affecting the rest of the structures. So for example if you delete a vertex with these structures without checking that all the faces incident on it have been removed you create a non consistent situation...

Similarly, but less dangerously, when you delete a face its vertices are left around so at the end you can have unreferenced floating vertices.
Allocator<MyMesh>::DeleteVertex(m,v);
Allocator<MyMesh>::DeleteFace(m,v);

If your algorithm performs deletion the size of a container could be different from the number of valid element of your meshes (e.g.:
m.vert.size() != m.vn 
m.face.size() != m.fn

Therefore when you scan the containers of vertices and faces you could encounter deleted elements so you should take care with a simple !IsD() check:
MyMesh::FaceIterator vi;
for(fi = m.face.begin(); vi!=m.face.end(); ++fi ) 
if(!(*fi).IsD()) //    <---- Check added
{
MyMesh::CoordType b = vcg::Barycenter(*fi); 
}

In some situations, particularly when you have to loop many many times over the element of the mesh without deleting/creating anything, it can be practical and convenient to get rid of deleted elements by explicitly calling the two garbage collecting functions:
Allocator<MyMesh>::CompactVertexVector(m);
Allocator<MyMesh>::CompactFaceVector(m);

After calling these function it is safe to not check the IsD() state of every element and always holds that:
m.vert.size() == m.vn 
m.face.size() == m.fn

Note that if there are no deleted elements in your mesh, the compactor functions returns immediately.


Adjacency relations


VCG meshes DO NOT store edges, only vertex and triangles. Even the basic adjacdncy relations has to be explicitly computed. We always try to do not store per-edge information and keep them only more or less implicitly. This is simply there are many algorithms that do not require it and the cost of updating/storing should be avoided when possible. In many cases algorithms that seems based on some kind


Counting border edges (without topology)


Typical example are border flags. Each face keep a bit for each of its sides saying if that face has a boundary on that side or not. This information can be accessed by mean of the IsB(i) function. To compute the border flags there are various algorithm according to the available topological informations.
Allocator<MyMesh>::CompactFaceVector(m);
UpdateFlags<MyMesh>::FaceBorderFromNone(m);
int BorderEdgeCounter=0;
MyMesh::FaceIterator fi;
for(fi = m.face.begin(); fi!=m.face.end(); ++fi ) 
{
for(int i=0;i<3;++i) 
if((*fi).IsB(i)) BorderEdgeCounter++; 
}


Counting border edge (using FF adjacency)


When your mesh as Face-Face adjacency the FFp(i) member store the pointer of the face that is adjacent to the current face along the i-th edg
int BorderEdgeCounter=0;
MyMesh::FaceIterator fi;
for(fi = m.face.begin(); fi!=m.face.end(); ++fi ) 
{
for(int i=0;i<3;++i) 
if((*fi).FFp(i) == &*fi) BorderEdgeCounter++; 
}

or alternatively using the same flag based approach as above
UpdateFlags<MyMesh>::FaceBorderFromFFAdjacency(m);
int BorderEdgeCounter=0;
MyMesh::FaceIterator fi;
for(fi = m.face.begin(); fi!=m.face.end(); ++fi ) 
{
for(int i=0;i<3;++i) 
if((*fi).IsB(i)) BorderEdgeCounter++; 
}

§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§

Ref.

http://meshlab.sourceforge.net/wiki/index.php/Accessing_the_mesh

meshlab VCG lib tutorial

VCG Lib is mostly made of header files (and its core part it's only header files). Just download the tarball from here and uncompress it in a folder, e.g. named vcg, inside you compiler "include" directory. Afterwards, you will include the file you need.

Inside vcg folder you will find 4 sub-folders:
  • vcg: this is the core of the library, where all the algorithms and data structures are defined. This part is pure, quite heavily templated, C++ code with STL support for common data structures and algorithms. You will not find a single include from here to anything else than standard libraries. Note that core part is made of header files (.h files) only.
  • wrap: here you will find the wrapping of VCG concepts towards specific needs/contexts/libraries. For example you will find all the code to import/export meshes from the hard disk in many formats, or the routines for rendering triangle meshes with OpenGL, supports for common GUI tools like a trackball, and so on..
  • apps: this folder contains the command line applications developed with the VCG Lib. Many (much more) examples can be found in MeshLab. The apps/simple directory contains a sub-collection of very basic apps. A good starting point for beginners!
  • docs: documentation lives here (including this tutorial)

ref.

http://vcg.sourceforge.net/index.php/Tutorial

3D mesh meshlab Discussion Forums: Users

http://sourceforge.net/forum/forum.php?forum_id=499532

mesh lab alignment registration

First of all you should have well understood the layers mechanism in MeshLab and the fact that each mesh can have an transformation matrix. The alignment process simply modify the transformation of each layer.

The main idea is that you iteratively glue your misaligned meshes over the already aligned ones. A mesh that is aligned toghether with a set already aligned mesh is said being Glued (a * is shown near to its name). Initially all the meshes are 'unglued'. You task is to roughly align all your meshes.

Once the mesh are glued in a rather good initial position you can start the Alignment Process: the system chooses what meshes have some overlapping part and for each pair of meshes the system starts a ICP alignment algorithm that precisely align the chosen pair. At the end of the process all the glued meshes will hopefully be aligned toghether.

Key Concepts:
  • ICP: Iterated closed point: The basic algorithm that automatically precisely align a moving mesh M onto a fixed one F. The main idea is that we choose a set of (well distributed) points over M and we search on F the corresponding nearest points. These pairs are used to find the best rigid transformation that bring the points of M onto their corresponding on F. ICP has a lot of tunable parameters.
  • Global Alignment: also known as multiview registration. A final step that evenly distributes the alignment error among all the alignments in order to avoid the biased accumulation of error.
  • Absolute Scale. The parameters of the alignment tool are in absolute units, and the defaults are ok for a standard scanner outputting meshes in millimeter units. So for example the target error (e.g. the error that the ICP try to achieve, is 0.05 mm something that can be achieved with a good scanner. Obviously if your range maps are in a different unit (microns, kilometers, ... ) you have to adjust the default alignment parameters, otherwise the alignment process will fail.

Ref.

http://meshlab.sourceforge.net/wiki/index.php/Alignment

MeshLab documentation

MeshLab is a advanced mesh processing system, for the automatic and user assisted

editing,

cleaning,

filtering

converting

and rendering

of large unstructured 3D triangular meshes.

MeshLab is actively developed by the a small group of people at the Visual Computing Lab at the ISTI - CNR institute, a large group of university students and some great developers from the rest of the world.

For the basic mesh processing tasks and for the internal data structures the system relies on the GPL VCG library

Ref:

http://meshlab.sourceforge.net/wiki/index.php/MeshLab_Documentation

Monday, July 21, 2008

K-3D = 3D modeling, animation, and rendering system

K-3D is the free-as-in-freedom 3D modeling, animation, and rendering system for GNU / Linux, Posix, and Win32 operating systems. K-3D features a robust, object-oriented plugin architecture, designed to scale to the needs of professional artists, and is designed from-the-ground-up to generate motion-picture-quality animation using RenderMan-compliant render engines. We strongly recommend the Aqsis render engine for use with K-3D.

K-3D's innovative interactive tutorial system will introduce you to basic use of the program. New tutorials can easily be recorded and shared with the rest of the community.

K-3D allows you to create and edit documents in multiple realtime OpenGL solid, shaded, texture-mapped views. You can even model, animate, and interact with animations while they play back for maximum productivity!

The following features apply to the 0.5/0.6 source tree:


Platforms


  • GNU / Linux 
  • Win32 ().
  • MacOSX ().
  • BSD ().
  • Solaris ().

Geometry Formats: Wavefront OBJ, GTS and a raw format are fully supported, other ones are optional and depend on PLIB installation. Experimental plugins include OpenFX, OFF, RIB and X formats.

Mesh Viewer

http://mview.sourceforge.net/

MS Windows executable


mview-win-0.3.1.zip (2.4MB)

Mesh Viewer is an easy to use lightweight application for displaying three dimensional models (triangular meshes) from a variety of file formats. It uses OpenGL to render the models.

Mesh Viewer supports the following 3D file formats:
  • PMesh forma (used at the Vision group of the University of Edinburgh)
  • GTS format (from the Gnu Triangulation Library)
  • Geomview format (only format "OFF" or "COFF")
  • PLY format (only ASCII format)
  • VRML 1.0 format
  • VRML 2.0 format (VRML97)
  • Visualisation Toolkit VTK format (ASCII POLYDATA only)
  • Alias Wavefront / Java 3D OBJ format (ASCII polygon data only).

A short description of the features and capabilities of some of the supported 3D formats can be found here.

GTS GNU Triangulated Surface Library--projects

Mesh Viewer
    The Mesh Viewer is an easy to use lightweight application to display triangular meshes from a variety of file formats (see 3D formats). It uses the OpenGL API to render the models.




Divipro
    The Divipro (Distributed Interactive VIrtual PROtotyping) project is a European Commission funded initiative involving partners from the UK, Spain, Germany and France. The consortium partners aim to build and evaluate a prototype system for distributed computer aided design (CAD) for mechanical engineering applications.




The Chips project
    The Chips project is a project to put together a usable CAD/CAM (Computer Aided Design/Computer Aided Manufacturing) system for the Linux platform.




K-3D
    K-3D is a free-as-in-freedom 3D modeling and animation system for GNU/Linux and Win32.




TriAreo
    TriAero is the Triangulated Aerodynamics Suite; a collection of Open Source Free Software programs intended to perform simplified aerodynamics calculations over unstructured 3D bodies.

FREE VRML Viewer and matlab

FREE VRML Viewer and matlab, virtual reality toolbox:
download:

http://www.orbisnap.com/download2.html

gallery:

http://www.orbisnap.com/gallery.html

The examples can be viewed also directly using standard VRML 97 browser plug-ins by clicking the corresponding "View virtual scene" links.

see some examples that were created using Virtual Reality Toolbox, a tool that lets you view and interact with dynamic system simulations           in a 3-D virtual reality environment. All of the behavioral dynamics of the examples are being driven by MATLAB® and Simulink® developed by             The MathWorks, Inc. that allow effective creating dynamic models of real systems physics.

Solar System



This model represents the dynamics of inner Solar System (Sun, Mercury, Venus, Earth + Moon, Mars). For visualization purposes, the relative planet sizes to their distances and the distance between Moon and Earth were adjusted. Otherwise, the model is a good approximation of Solar system dynamics.

View virtual scene
Download zipped VRML world