FAQ: Understanding Memory and Filters (Wavelet): Thresholding: Difference between pages

From MIPAV
(Difference between pages)
Jump to navigation Jump to search
MIPAV>Olgavovk
 
m (1 revision imported)
 
Line 1: Line 1:
When MIPAV performs a function, such as visualizing an image file, it uses RAM on your computer. When you run MIPAV for the first time you must specify the maximum amount of memory (it calls the maximum heap size in the dialog box) that you would like to allocate for MIPAV, so it can take the full advantage of the memory resources available in your machine. The default value is 1000 MB.  The amount of memory you can allocate to MIPAV is limited by how much RAM is installed on your system.
The wavelet transform or wavelet analysis is a solution to overcome the shortcomings of the Fourier transform. In wavelet analysis, the modulated window is shifted along the signal, and for every position, the spectrum is calculated. Then, this process is repeated many times with a slightly shorter (or longer) window for every new cycle. In the end, the result appears as a collection of time-frequency representations of the signal, all with different resolutions. Since the modulated window is fully scalable, this solves the signal-cutting problem which arises in the Fourier transform.


== User permissions ==
Because the result appears as a collection of time-frequency representations of the signal, we can speak of a multi resolution analysis. However, in the case of wavelets, we normally do not speak about time-frequency representations, but about time-scale representations, scale being in a way the opposite of frequency, because the term frequency is reserved for the Fourier transform.
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.


== Memory limitations ==
{| width="90%" border="1" frame="hsides" frame="hsides"
 
{| class="wikitable" style="text-align: center; color: black;"
|-
|  '''OS'''
| '''Max memory
|-
|Windows 32
|1.3 GB
|-
|Windows 64
|196 TB
|-
|Mac OS
|196 TB
|-
|Linux 32
|4 GB
|-
|-
|Linux 64
| width="9%" valign="top" |
|196 TB
[[Image:noteicon.gif]]
| width="81%" bgcolor="#B0E0E6" |
[http://mipav.cit.nih.gov/documentation/HTML Algorithms/FiltersWaveletThresholding.html For more information about the algorithm, refer to MIPAV Volume 2 User Guide on the MIPAV web site:{http://mipav.cit.nih.gov/documentation/HTML Algorithms/FiltersWaveletThresholding.html} ]
|}
|}


'''Comment:''' These memory allocations are limited by how much RAM is installed on your computer.
<br />


== How can I allocate (more) memory for MIPAV? ==
== Background ==
=== Outline of the algorithm ===


=== When you are installing MIPAV ===
The image is expanded so that all dimensions are powers of 2 and there is zero padding going past each original boundary by the coefficient number equals 2.


[[File:JvmMemoryLimit.png|500px|thumb|right|Installing MIPAV: the JVM Memory Limit tab]]
# The image is transformed into wavelet coefficients using the threshold type selected by the user.
# The signal reconstructed from wavelet coefficients.
# Then, an inverse wavelet transform is performed.
# The image is stripped down to its original size. The data is clamped so as not to exceed the bounds of the data type of the image into which it is imported.


Starting [http://mipav.cit.nih.gov/download.php version 5.4.2] the easiest way to allocate memory in MIPAV is to do it when you are installing MIPAV. You can define the memory value in the JVM Memory Limit pane. The default value is set to 1000 MB. In the Pre-Installation summary pane, you can review memory settings, and then return back to the JVM Memory Limit pane and adjust them, if needed.
{| width="90%" border="1" frame="hsides" frame="hsides"
|-
| width="9%" valign="top" |
[[Image:noteicon.gif]]
| width="81%" bgcolor="#B0E0E6" | Note: the forward and inverse Daubechies wavelet transform routines are taken from Numerical Recipes in C, The Art of Scientific Computing 2nd edition by William H. Press, Saul A. Teukolsky, William T. Vetterling, and Brian P. Flannery, Cambridge University Press, 1997, Chapter 13.10, pp. 591 606.
|}


In case you figured out later that you need [[#HowMuchMemory | more memory]], you can still make adjustments using the Check java-runtime Memory Allocation dialog box [[#ChangeJava |options]]. See instructions provided for different operational systems below.
<br />


== Image types ==


<div id="WindowsMemory"></div>
2D and 3D black and white images.
=== Windows users: adjusting memory settings ===
<div id="ChangeJava"></div>
<ol>
<li>Login to your computer under the administrative account, or under the user account who installed MIPAV. </li>


<li>Select Help &raquo; Memory allocation in the Main MIPAV window. The Check java-runtime Memory Allocation dialog box opens.</li>
== Applying the Wavelet Thresholding algorithm ==


<li>In the dialog box, change the maximum heap size number so it reflects the maximum amount of memory you might need. Note that for Windows 32, there is a 1.3 GB limit for memory allocation.</li>
To use this algorithm, do the following:


# To apply the algorithm, do the following:
# Open an image of interest.
# Navigate to Algorithms &gt; Filters Wavelet &gt; Thresholding.
# In the Wavelet Thresholding dialog box that appears, complete the following fields:
#* In the Number of Terms list box, select 4, 12 or 20. Numbers of Terms here means the number of wavelet vanishing moments or an approximation order;
#* In the Wavelet Threshold box, specify the threshold value;
#* To specify the threshold type, use the radio buttons: Hard, Soft, Nonnegative garrote, and SCAD;
#* To display the log magnitude wavelet image, check the corresponding box. Displaying this image will help you to adjust the algorithm settings;
#* Select the destination, use the New Image option to view the result image in a new frame, or use the Replace Image option o view the result image in the same frame.
# Press OK. The algorithm begins to run and the new image appears in the specified frame.


[[File:MemoryAllocation.png|429px|thumb|center| The Change java-runtime Memory Allocation dialog box]]


<li>Click OK to close the dialog box.</li>
=== Wavelet Thresholding dialog box ===
<div>


<li>You must restart of MIPAV for the changes to take effect. To exit MIPAV, select File &raquo; Exit. Then, restart the software.</li>
{| border="1" cellpadding="5"
</ol>
|+ <div>'''Figure 1. Wavelet Thresholding dialog box ''' </div>
 
|-
Now, when more memory is needed to perform a certain task, MIPAV allocates it until the memory reaches the maximum heap size you specified. You can also access this dialog anytime and change the memory allocation parameter as you wish.
|
 
<div>'''Number of terms''' </div>
<div id="LinuxMemory"></div>
|
 
<div>- this is the number of wavelet vanishing moments or an approximation order. Select 4, 12 or 20. </div>
=== Linux users: adjusting memory settings ===
| rowspan="8" colspan="1" |
 
<div><div align="left">[[Image:FiltersWaveletThresholdingaq.jpg]]</div> </div>
To change the amount of memory allocated for MIPAV use, you need to run MIPAV using an account that has write-permission to the directory where MIPAV is installed, such as an administrator. The heap size is set in the mipav.lax file located in the directory where MIPAV is installed. E.g. <span style="font-family:courier">/usr/share/mipav </span>(and not within your own user mipav folder, e.g. <span style="font-family:courier">~/mipav</span>). Therefore, you need to run MIPAV with the appropriate permissions to modify files in that directory for the one time when you use the memory allocation tool.
|-
 
|
<ol>
<div>'''Wavelet threshold''' </div>
<li> Login to your computer under the administrative account, or under the user account who installed MIPAV.</li>
|
<li> Select Help &raquo; Memory Allocation in the Main MIPAV window. [[#ChangeJava | The Check java-runtime Memory Allocation dialog box]] opens.</li>
<div>- use to specify the threshold value </div>
<li> In the dialog box, change the maximum heap size number so it reflects the maximum amount of memory you might need.</li>  
|-
<li> Click OK to close the dialog box.</li>
| rowspan="4" colspan="1" |
<li> You must restart of MIPAV for the changes to take an effect. To exit MIPAV, select File &raquo; Exit. Then, restart the software.</li>
<div>'''Hard''' </div><div>'''Soft''' </div><div>Nonnegative garrote </div><div>SCAD </div>
</ol>
| rowspan="4" colspan="1" |
 
<div>- use these radio buttons specify the threshold type. </div>
<div id="MacMemory"></div>
|-
 
|-
=== Mac OS users: adjusting memory settings ===
|-
 
|-
Follow the instructions provided to the [[#LinuxMemory | Linux users]]. The only difference is that in Mac OS the <span style="font-family:courier">mipav.lax</span> file is called <span style="font-family:courier">mipav.command.lax</span>, but it looks just the same.
|
 
<div>'''Display log magnitude wavelet image''' </div>
<div id="MipavLax"></div>
|
=== mipav.lax file ===
<div>- check this box to display the log magnitude wavelet image. Displaying this image will help you to adjust the algorithm settings. </div>
 
|-
To adjust memory settings, MIPAV needs an access to the <span style="font-family:courier">mipav.lax</span> file located in the directory where MIPAV is installed. That’s why you need the appropriate permissions to make changes in this file. See also: [[MIPAV configuration files#LaunchAnywhere | MIPAV LAX files.]]
|
 
<div>'''New image''' </div>
'''mipav.lax file: the allocating memory section'''
|
 
<div>use this to view the result image in a new frame. </div>
<blockquote>
|-
LAX.NL.JAVA.OPTION.JAVA.HEAP.SIZE.INITIAL <br />
|
 
<div>'''Replace image''' </div>
&#35;  ----------------------------------------- <br />
| rowspan="1" colspan="2" |
 
<div>use this to view the result image in the same frame. </div>
&#35;  Java start up heap size<br />
|-
 
|
lax.nl.java.option.java.heap.size.initial=1048576000 <br />
<div>'''OK''' </div>
 
| rowspan="1" colspan="2" |
&#35;  LAX.NL.JAVA.OPTION.JAVA.HEAP.SIZE.MAX <br />
<div>Applies the algorithm according to the specifications in this dialog box. </div>
 
|-
&#35;  ------------------------------------- <br />
|
 
<div>'''Cancel''' </div>
&#35;  Java maximum heap size <br />
| rowspan="1" colspan="2" |
 
<div>Disregards any changes that you made in the dialog box and closes this dialog box. </div>
lax.nl.java.option.java.heap.size.max=1048576000 <br />
|-
</blockquote>
|
 
<div>'''Help''' </div>
Note: For Mac OS <span style="font-family:courier">mipav.lax file</span> is called <span style="font-family:courier">mipav.command.lax</span>, but it looks just the same.
| rowspan="1" colspan="2" |
 
<div>Displays online help for this dialog box. </div>
=== Other situations ===
|}
[[File:OptionsMIpav.png|290px|thumb|right|The MIPAV Options dialog box]]
 
If you change the amount of allocated memory (the maximum heap size) and receive the following error message:
<blockquote>
"Heap size settings in the environment startup file either do not match those in the Preference file, or are non-existent. Memory Allocation will display so you can ensure this is correct." </blockquote>
 
And when you set a new number: in the Change java-runtime Memory Allocation dialog box, the following error message appears:
 
<blockquote>"Error writing to starting options file. No changes were made."</blockquote>
 
'''In order to fix that problem:'''
 
This is a common message when you have multiple versions of MIPAV installed on your computer and you switch between them. If you don’t want this warning to show up, you can avoid this by un-checking LAX/Preferences memory check option in the mipav.preferences file. This could be done via the MIPAV Options dialog box.
 
<ol>
<li> Select Help &raquo; Mipav Options in the Main MIPAV window. The MIPAV Options dialog box opens.</li>
<li> In the dialog box, go to the Other tab.</li>
<li> Un-check the LAX/Preferences memory check box.</li>
<li> Click Apply. The change will take place immediately.</li>
</ol>
 
<div id="HowMuchMemory"></div>
== How much memory does MIPAV require to run? ==
 
MIPAV requires a base of at least 10 Mb of random access memory (RAM). However, to correctly display image files and to quantify the data, you need to allocate more memory, use disk swap space, or install additional memory beyond this base. Each time MIPAV is installed, it always defaults to 100 Mb.
 
=== What affects memory requirements? ===
 
Memory requirements fluctuate depending on the size and number of image files that are open at the same time. Factors affecting memory requirements are the following:
1) the physical size of image files (i.e., 1.2 Mb); 2) the number of images opened, because working on more than one image file at the same time requires more memory.
 
'''Note:'''Java provides a method called Garbage Collector that 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 (refer to [[#HowFreeMemory | How can I free memory?]] ). <br />
 
<div id="MemoryNeeded"></div>
=== How can I determine the amount of additional memory needed? ===
 
To determine the amount of additional memory needed:
<ol>
<li> Multiply the size of the largest image file that you want to process by 10.</li>
<li>Multiply the results by the number of image files that you want to display simultaneously.</li>
<li> Add this amount to the 10-Mb base memory to result in the total amount of memory typically needed.</li>
</ol>
 
==== Example 1: Memory calculation====
 
If an image file is 2 Mb and you only want to display one image file at a time, you must allocate an additional 20 Mb of RAM to the base memory of 10 Mb to result in a memory requirement of 30 Mb.
 
<blockquote>
2 Mb Size of image file x 10
<hr width="20%" />
20 Mb Memory required for displaying and processing 1 image file
 
+
 
10 Mb Base memory required for running MIPAV
<hr width="20%" />
30 Mb Total memory required
</blockquote>
 
==== Example 2: Memory calculation ====
 
If the largest size image file is 2 Mb and you want to display 3 image files simultaneously, multiply 2 Mb by 10. Then multiply that sum by 3. Add that total to the base memory of 10 Mb to yield a memory requirement of 70 Mb.
 
<blockquote>
2 Mb Largest size image file x 10
<hr width="20%" />
20 Mb Memory required for displaying 1 image file
x 3 Number of images to display and process simultaneously
<hr width="20%" />
60 Mb Memory required to display 3 image files
 
+
 
10 Mb Base memory required for running MIPAV
<hr width="20%" />
70 Mb Total memory required
</blockquote>
 
=== How can I determine how much memory is currently being used? ===
[[File:MemoryUsage.jpg|400px|thumb|right|The Memory Monitor dialog box]]
 
In the main MIPAV window, select Help &raquo; Memory Usage (or press '''Ctrl+M'''). The Memory Monitor dialog box appears. The dialog box shows how much memory is allocated and the amount of memory that is being used. The graph displays a pictorial representation of the ratio of allocated memory and amount of memory used. It shows the memory usage during the past 3 minutes and 45 seconds.
 
'''Note: '''You can leave this window open if you want to constantly monitor your memory resources.<br />
 
<div id="HowFreeMemory"></div>
 
== How can I free memory? ==
 
 
[[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.
 
=== To free memory, do the following procedure periodically: ===
 
<ul>
<li> Click the Garbage Collector button on the main MIPAV window.</li>
<li> Select Help &raquo; Memory Usage in the main MIPAV window. The Memory Monitor dialog box appears. Click Free Memory. The system clears all unnecessarily reserved memory.</li>
</ul>
 
 
== Videos ==
This video tutorial explains how to load images into MIPAV and change the memory allocation - [http://www.youtube.com/embed/npSYWYJa530 play].
 
== See also: ==
*[[Getting Started Quickly with MIPAV]]
*[[Allocating Memory in MIPAV]]
*[[Opening and loading image files]]
 
Next: [[FAQ: Customizing MIPAV]]
 
[[Category: Help]]


[[Category: FAQ]]
[[Category:Help]]
[[Category:Help:Algorithms]]

Latest revision as of 16:28, 9 February 2024

The wavelet transform or wavelet analysis is a solution to overcome the shortcomings of the Fourier transform. In wavelet analysis, the modulated window is shifted along the signal, and for every position, the spectrum is calculated. Then, this process is repeated many times with a slightly shorter (or longer) window for every new cycle. In the end, the result appears as a collection of time-frequency representations of the signal, all with different resolutions. Since the modulated window is fully scalable, this solves the signal-cutting problem which arises in the Fourier transform.

Because the result appears as a collection of time-frequency representations of the signal, we can speak of a multi resolution analysis. However, in the case of wavelets, we normally do not speak about time-frequency representations, but about time-scale representations, scale being in a way the opposite of frequency, because the term frequency is reserved for the Fourier transform.

Noteicon.gif

Algorithms/FiltersWaveletThresholding.html For more information about the algorithm, refer to MIPAV Volume 2 User Guide on the MIPAV web site:{http://mipav.cit.nih.gov/documentation/HTML Algorithms/FiltersWaveletThresholding.html}


Background

Outline of the algorithm

The image is expanded so that all dimensions are powers of 2 and there is zero padding going past each original boundary by the coefficient number equals 2.

  1. The image is transformed into wavelet coefficients using the threshold type selected by the user.
  2. The signal reconstructed from wavelet coefficients.
  3. Then, an inverse wavelet transform is performed.
  4. The image is stripped down to its original size. The data is clamped so as not to exceed the bounds of the data type of the image into which it is imported.

Noteicon.gif

Note: the forward and inverse Daubechies wavelet transform routines are taken from Numerical Recipes in C, The Art of Scientific Computing 2nd edition by William H. Press, Saul A. Teukolsky, William T. Vetterling, and Brian P. Flannery, Cambridge University Press, 1997, Chapter 13.10, pp. 591 606.


Image types

2D and 3D black and white images.

Applying the Wavelet Thresholding algorithm

To use this algorithm, do the following:

  1. To apply the algorithm, do the following:
  2. Open an image of interest.
  3. Navigate to Algorithms > Filters Wavelet > Thresholding.
  4. In the Wavelet Thresholding dialog box that appears, complete the following fields:
    • In the Number of Terms list box, select 4, 12 or 20. Numbers of Terms here means the number of wavelet vanishing moments or an approximation order;
    • In the Wavelet Threshold box, specify the threshold value;
    • To specify the threshold type, use the radio buttons: Hard, Soft, Nonnegative garrote, and SCAD;
    • To display the log magnitude wavelet image, check the corresponding box. Displaying this image will help you to adjust the algorithm settings;
    • Select the destination, use the New Image option to view the result image in a new frame, or use the Replace Image option o view the result image in the same frame.
  5. Press OK. The algorithm begins to run and the new image appears in the specified frame.


Wavelet Thresholding dialog box

Figure 1. Wavelet Thresholding dialog box
Number of terms
- this is the number of wavelet vanishing moments or an approximation order. Select 4, 12 or 20.
FiltersWaveletThresholdingaq.jpg
Wavelet threshold
- use to specify the threshold value
Hard
Soft
Nonnegative garrote
SCAD
- use these radio buttons specify the threshold type.
Display log magnitude wavelet image
- check this box to display the log magnitude wavelet image. Displaying this image will help you to adjust the algorithm settings.
New image
use this to view the result image in a new frame.
Replace image
use this to view the result image in the same frame.
OK
Applies the algorithm according to the specifications in this dialog box.
Cancel
Disregards any changes that you made in the dialog box and closes this dialog box.
Help
Displays online help for this dialog box.