Allocating Memory in MIPAV and BSpline registration: Detecting folding: Difference between pages

From MIPAV
(Difference between pages)
Jump to navigation Jump to search
m (1 revision imported)
 
MIPAV>Ruida cheng
 
Line 1: Line 1:
When you run MIPAV for the first time you must specify the amount of memory that you would like to allocate, so that MIPAV can take the full advantage of the memory resources available in your machine. For more information about user permissions, memory limits, and memory usage in different operation systems, refer to: [[FAQ: Understanding Memory]].
== Contents ==


'''Note:''' [[FAQ: Understanding Memory | MIPAV’s memory allocation]] is a program-level feature and it affects all users of a given MIPAV installation. You can only change the amount of allocated memory, if you are running MIPAV using an administrative account.
[[B-Spline Automatic Registration]] chapter contains several sections:


== To allocate memory when installing MIPAV ==
*[[B-Spline Automatic Registration]]


Refer to [[FAQ: Understanding Memory]].
*[[BSpline registration: Detecting folding | B-Spline automatic registration: Detecting folding - you are here]]


== To monitor memory usage ==
*[[Examples of BSpline registration]]
[[File:MemoryUsage.jpg|400px|thumb|right|The Memory Monitor dialog box]]


When MIPAV performs a function, such as visualizing an image file, it uses memory. When the function completes (i.e., the visualized image closed), you can manually free the memory so it can be used for another function. The first step is to view how much memory is currently being used and to free needlessly reserved memory. Then, if necessary, you may need to allocate additional memory.
*[[User Dialogs in MIPAV | B-Spline Automatic Registration Dialog box]]


=== To determine how much memory is currently being used by MIPAV ===
== BSpline registration - Detecting folding ==


<ol>
The situation of folding in a 2D or 3D B-spline transformation occurs when there is a negative value in the computed deformation. The computation of the deformation is described in Section "Deformation". This section describes a method for detecting if such folding occurs given the current positions for the lattice of the B-spline control points. Given the lattice structure of the B-spline control points, folding can be detected by geometric means. In two dimensions, consider any interior control point and its 8 neighboring control points forming a polygon. Construct 8 triangles involving the chosen interior control point each time with the 8 pairings of adjacent control points on the polygon perimeter. The intersection of any one triangle with the other 7 triangles should each be empty in order for there to be no folding. Alternatively, the area of the polygon should be identical to the union of the areas of the 8 triangles.
<li>Select Help &raquo; Memory Usage in the MIPAV window. The Memory Monitor dialog box appears. </li>
<li>The Memory Monitor dialog box shows how much memory is allocated and how much memory has been used. The vertical bar on the right of the window displays a pictorial representation of the ratio of allocated memory or amount of memory used. The chart shows the memory usage for the past 3 minutes and 45 seconds. The chart is updated every second.</li>
<li>If you want to constantly monitor your memory resources, you can leave the Memory Monitor dialog box open on your desktop. Otherwise, close it. </li>
</ol>


To figure out how much memory you actually need, refer to [[FAQ: Understanding Memory#MemoryNeeded | How much memory does MIPAV require to run?]]
The issues are similar in three dimensions by considering the 26 neighboring control points forming a polyhedron. In this case, 48 tetrahedrons are constructed involving the chosen interior control point each time along with the triples of control points from the 48 triangles forming the polyhedron mesh. The intersection of any one tetrahedron with the other 47 tetrahedrons should each be empty in order for there to be no folding. Alternatively, the volume of the polyhedron should be identical to the union of the volumes of the 48 tetrahedrons.


== To manually free memory ==
A sufficient but not necessary condition to conclude that folding occurs in the case of two dimensions is the premise that any interior control point is outside the polygon formed by its 8 neighboring control points. In the case of three dimensions, the premise is that any interior control point is outside the polyhedron formed by its 26 neighboring control points.


[[File:GarbageCollector.jpg|frameless]] As Java-based programs run, they often leave old variables, objects, or constructors in memory. For instance, if you delineate a VOI, the coordinates of the contours may remain in memory even after you close the image. Java provides a method called the ''garbage collector'' (or ''memory recycling'') that automatically freeing objects that are no longer referenced by the program and clears all unnecessarily reserved memory. Generally, the software does this automatically when free memory becomes very limited. However, you can run the garbage collector at any time to free memory by clicking the Garbage Collector button on the main MIPAV window. You can also free memory in the Memory Monitor dialog box by clicking the Free Memory button.<br />
A condition that is both necessary and sufficient to conclude that folding occurs does exist for both 2D and 3D. In the case of two dimensions, again consider the 8 triangles formed by the chosen interior control point each time with the 8 pairings of adjacent control points on the polygon perimeter. It is important that these triangles formed by control points from the lattice be consistently counterclockwise ordered. For each triangle, let ''A =(a0,a1) ''be the 2D coordinates of the chosen interior control point, and let ''B =(b0,b1)'' and ''C =(c0,c1)'' be the 2D coordinates of the other two triangle control points taken in counterclockwise order. The normal to the plane which contains this triangle can be computed from the (right handed) cross product of the two vectors AB and AC. One way to express the calculation of the cross product involves the construction of the following matrix which contains the three triangle point coordinates:


<div id="Eq13"></div>


== To allocate additional memory ==
[[File:BSplineRegistrationEq13.jpg|left|Equation 13]]
[[File:MemoryAllocation.jpg|429px|thumb|right| The Change java-runtime Memory Allocation dialog box]]


=== For Windows users: ===


<ol>
The determinant of this matrix is twice the signed area of the triangle. Starting with consistently counter clockwise ordered triangles from the initially placed lattice of control points, the determinant of this matrix should remain positive as control point positions are moved. The determinant will become negative when the triangle ''folds''.
<li> Select Help &raquo; Memory allocation in the MIPAV window. The Change JavaRuntime Memory Allocation dialog box opens.</li>
<li>Change the maximum heap size number so that it reflects the maximum amount of memory that should be allocated. In a Microsoft Windows 32 system, you can specify a maximum of 1.3 Gb. </li> 
<li>Click OK to close the dialog box.</li>
<li>Restart  MIPAV for the changes to take effect. To exit MIPAV, select File &raquo; Exit. Then, restart the software.</li>
</ol>


Now, when additional memory is needed, MIPAV allocates it until the memory reaches the maximum heap size that you specify.
The premise for the necessary and sufficient condition to detect when folding occurs extends to three dimensions. Consider the 48 tetrahedrons formed by the chosen interior control point each time with the triples of adjacent control points from the 48 triangles forming the polyhedron mesh. It is important that the tetrahedrons formed by the control points from the lattice be consistently counterclockwise ordered, in the 3D sense. For each tetrahedron, let ''A = (a0,a1,a2)'' be the 3D coordinates of the chosen interior control point, and let ''B = (b0,b1,b2)'', ''C = (c0,c1,c2)'', and ''D = (d0,d1,d2)'' be the 3D coordinates of the other three tetrahedron control points taken in counterclockwise order. Extending the matrix determinant formulation used for two dimensions to three dimensions, the following matrix is constructed which contains the four tetrahedron point coordinates:


=== For Linux users: ===
<div><div align="left">
Refer to [[FAQ: Understanding Memory]].
<math>
\begin{bmatrix} a_0 & a_1 & a_2 & 1 \\ b_0 & b_1 & b_2 & 1 \\ c_0 & c_1 & c_2 & 1 \\  d_0 & d_1 & d_2 & 1 \\ \end{bmatrix}
</math></div> </div>


=== For Mac OS users: ===
The determinant of this matrix is 6 times the signed volume of the tetrahedron. Starting with consistently counterclockwise ordered tetrahedrons from the initially placed lattice of control points, the determinant of this matrix should remain positive as control point positions are moved. The determinant will become negative when the tetrahedron ''folds''.
Refer to [[FAQ: Understanding Memory]].


== BSpline registration - Image types ==


=== If you need even more memory ===
The algorithm can be applied to 2D and 3D color (RGB) and grayscale images


You can allocate virtual memory or disk swap space if there is free space on your hard drive. For instructions on how to do this, refer to the documentation for your system. If you cannot assign more virtual memory or disk swap space, you may need to install additional memory.
=== Support for color images ===


=== Memory limitations ===
The registration of 2D and 3D color images involves first converting the three color channels of values at each sample in the source and target color images to create single channel source and target intensity images. Once the conversion has been done, the single channel intensity source and target images are registered as described in [[BSplineRegistrationOV_withMath.html#wp1011586|Background]]. The resulting transformation map is extracted from the registration which is then used to interpolate the original source color image in order to generate the output registered source color image.


Refer to [[FAQ: Understanding Memory]].
Normally, the three color channels represent red, green, and blue intensities, and so the conversion to a single channel value usually represents overall intensity. In this manner, the conversion is simply a weighted average of the three color channels where separate weights can be provided for each channel. The current implementation uses equal weights for each channel.


=== Support for 2.5D images ===


=== For more information ===
A 2.5D image is actually a 3D image containing a series 2D slice images. The registration of a 2.5D intensity or color image involves a 2D registration of each slice in the 2.5D image to a reference slice also in the same 2.5D image. The reference slice can either be a xed slice or the previous slice. The resulting output registered 2.5D image contains the same number of slices as the original 2.5D image where the sample values in a slice of the registered output are from the same slice of the original only "warped" by the B-spline registration transformation.
Refer to: [[FAQ: Understanding Memory]].
 
If the reference slice is fixed, then the reference slice will appear in the registered output as being unchanged. If the reference slice is the previous slice, then the first slice will be registered to the last slice.
 
 
== Next ==
 
*[[B-Spline Automatic Registration]]
 
*[[BSpline registration: Detecting folding | B-Spline automatic registration: Detecting folding - you are here]]
 
*[[Examples of BSpline registration]]
 
*[[User Dialogs in MIPAV | B-Spline Automatic Registration Dialog box]]


== See also: ==
*[[Opening and loading image files]]
*[[MIPAV toolbars]]
*[[Displaying MIPAV Toolbars]]
*[[Displaying images]]


[[Category:Help]]
[[Category:Help]]
[[Category: Getting started]]
 
[[Category:Help:Algorithms]]

Revision as of 18:39, 11 April 2012

Contents

B-Spline Automatic Registration chapter contains several sections:

BSpline registration - Detecting folding

The situation of folding in a 2D or 3D B-spline transformation occurs when there is a negative value in the computed deformation. The computation of the deformation is described in Section "Deformation". This section describes a method for detecting if such folding occurs given the current positions for the lattice of the B-spline control points. Given the lattice structure of the B-spline control points, folding can be detected by geometric means. In two dimensions, consider any interior control point and its 8 neighboring control points forming a polygon. Construct 8 triangles involving the chosen interior control point each time with the 8 pairings of adjacent control points on the polygon perimeter. The intersection of any one triangle with the other 7 triangles should each be empty in order for there to be no folding. Alternatively, the area of the polygon should be identical to the union of the areas of the 8 triangles.

The issues are similar in three dimensions by considering the 26 neighboring control points forming a polyhedron. In this case, 48 tetrahedrons are constructed involving the chosen interior control point each time along with the triples of control points from the 48 triangles forming the polyhedron mesh. The intersection of any one tetrahedron with the other 47 tetrahedrons should each be empty in order for there to be no folding. Alternatively, the volume of the polyhedron should be identical to the union of the volumes of the 48 tetrahedrons.

A sufficient but not necessary condition to conclude that folding occurs in the case of two dimensions is the premise that any interior control point is outside the polygon formed by its 8 neighboring control points. In the case of three dimensions, the premise is that any interior control point is outside the polyhedron formed by its 26 neighboring control points.

A condition that is both necessary and sufficient to conclude that folding occurs does exist for both 2D and 3D. In the case of two dimensions, again consider the 8 triangles formed by the chosen interior control point each time with the 8 pairings of adjacent control points on the polygon perimeter. It is important that these triangles formed by control points from the lattice be consistently counterclockwise ordered. For each triangle, let A =(a0,a1) be the 2D coordinates of the chosen interior control point, and let B =(b0,b1) and C =(c0,c1) be the 2D coordinates of the other two triangle control points taken in counterclockwise order. The normal to the plane which contains this triangle can be computed from the (right handed) cross product of the two vectors AB and AC. One way to express the calculation of the cross product involves the construction of the following matrix which contains the three triangle point coordinates:

Equation 13


The determinant of this matrix is twice the signed area of the triangle. Starting with consistently counter clockwise ordered triangles from the initially placed lattice of control points, the determinant of this matrix should remain positive as control point positions are moved. The determinant will become negative when the triangle folds.

The premise for the necessary and sufficient condition to detect when folding occurs extends to three dimensions. Consider the 48 tetrahedrons formed by the chosen interior control point each time with the triples of adjacent control points from the 48 triangles forming the polyhedron mesh. It is important that the tetrahedrons formed by the control points from the lattice be consistently counterclockwise ordered, in the 3D sense. For each tetrahedron, let A = (a0,a1,a2) be the 3D coordinates of the chosen interior control point, and let B = (b0,b1,b2), C = (c0,c1,c2), and D = (d0,d1,d2) be the 3D coordinates of the other three tetrahedron control points taken in counterclockwise order. Extending the matrix determinant formulation used for two dimensions to three dimensions, the following matrix is constructed which contains the four tetrahedron point coordinates:

The determinant of this matrix is 6 times the signed volume of the tetrahedron. Starting with consistently counterclockwise ordered tetrahedrons from the initially placed lattice of control points, the determinant of this matrix should remain positive as control point positions are moved. The determinant will become negative when the tetrahedron folds.

BSpline registration - Image types

The algorithm can be applied to 2D and 3D color (RGB) and grayscale images

Support for color images

The registration of 2D and 3D color images involves first converting the three color channels of values at each sample in the source and target color images to create single channel source and target intensity images. Once the conversion has been done, the single channel intensity source and target images are registered as described in Background. The resulting transformation map is extracted from the registration which is then used to interpolate the original source color image in order to generate the output registered source color image.

Normally, the three color channels represent red, green, and blue intensities, and so the conversion to a single channel value usually represents overall intensity. In this manner, the conversion is simply a weighted average of the three color channels where separate weights can be provided for each channel. The current implementation uses equal weights for each channel.

Support for 2.5D images

A 2.5D image is actually a 3D image containing a series 2D slice images. The registration of a 2.5D intensity or color image involves a 2D registration of each slice in the 2.5D image to a reference slice also in the same 2.5D image. The reference slice can either be a xed slice or the previous slice. The resulting output registered 2.5D image contains the same number of slices as the original 2.5D image where the sample values in a slice of the registered output are from the same slice of the original only "warped" by the B-spline registration transformation.

If the reference slice is fixed, then the reference slice will appear in the registered output as being unchanged. If the reference slice is the previous slice, then the first slice will be registered to the last slice.


Next