## Tuesday, October 6, 2009

### matlab and amira; how to integrate complex calculus into Amira using MATLAB

http://www.amiravis.com/documentation/521/amira/usersguide/tutmatlab.html

## 2.14 Using MATLAB Scripts

In this tutorial you will learn how to integrate complex calculus into Amira using MATLAB (The MathWorks, Inc) by the means of the CalculusMatlab module.

In order to use the CalculusMatlab module, MATLAB 7 must be correctly installed on your computer. The CalculusMatlab module establishes a connection to the MATLAB computational engine that was registered during installation. If you did not register during installation, on the Windows command line you can enter the command:
• matlab /regserver

The limitations of the CalculusMatlab module are listed in its documentation.

This tutorial covers the following topics:
2. Lowpass filtering on images.
3. Controlling the script with a time slider.
4. Thresholding on a volume.

### 2.14.1 Lowpass Filtering on Images

In this section we will learn how to apply a lowpass filter on an Amira image using the MATLAB Fourier transformation. This example shows how to pass data and control variables from Amira to MATLAB, execute a MATLAB script, and import the data back into Amira

.
• Load the lena.png image file located in subdirectory data/tutorials/matlab.
• Choose Luminance in the Channel Conversion field as shown in Figure 34.
• Right click on the green icon and choose CalculusMatlab from the Compute section.

A new red icon appears, the CalculusMatlab module that will try to connect to the MATLAB engine. This may take a while.

• Load the script lowpass.m located in subdirectory data/tutorials/matlab by clicking the Read button of the File port.
• Execute the script by clicking on the buffer button of the Execute port.
• Connect an OrthoSlice to the filtered image result.

The module uses the MATLAB computation engine which has its own user interface.

You can easily show or hide the MATLAB console using the checkbox in the options field. The MATLAB console is very useful for debugging purposes because it allows you to access variables of the MATLAB workspace. Any variable not cleared by the MATLAB "clear" command in the script is accessible in the MATLAB workspace, even after finishing the current CalculusMatlab computation (see the CalculusMatlab documentation).

 Figure 35: The CalculusMatlab module

In addition you can control scalar parameters of the script using time sliders:
• Create a time slider (File/Create/Data/Time).
• Connect the CalculusMatlab module to the time slider.
• Change the line cutoff=0.05 to cutoff=t in the script (see the CalculusMatlab documentation for more information about the keyword t).
• Click on the time slider and adjust the value that will be assigned to w. Right mouse click in the text field of the time slider and select Configure to adjust the data range of the parameters.

 Figure 36: Left: original Right: lowpass filtered

Note: To handle RGBA image filtering, you must load the image with Color Field Channel Conversion and treat each channel separately in the script.

### 2.14.2 Thresholding on a Volume

In this section we will learn how to apply a threshold to a volume. This is done by setting a value for a threshold. If the value for the voxel is less than the threshold, the voxel value is assigned the value of zero. If it is above the threshold, it is assigned a value of 255.
• Load the file lobus.am located in subdirectory data/tutorials.
• Right click on the green icon and choose CalculusMatlab from the Compute section.
• Load the script threshold.m located in subdirectory data/tutorials/matlab by clicking the Read button of the File port.
• Execute the script by clicking on the buffer button of the Execute port.

A new green icon appears, the Lattice that will hold the threshold result. Connect an OrthoSlice or a Voltex to see the result.

Note: Any variable accessed by MATLAB and pushed back into the Amira workspace will lose its voxel size information. You will need to correct the voxel size manually using the Crop Editor.

#### 1 comment:

1. je suis damande l'aide de cet logeciel amira
"colonne vértibrale