How to specify the location of a plugin in the MIPAV menu and Image Math: Difference between pages

From MIPAV
(Difference between pages)
Jump to navigation Jump to search
m (1 revision imported)
 
m (1 revision imported)
 
Line 1: Line 1:
By default, the location of a plugin within the MIPAV GUI is specified by the PlugIn interface that the main plugin class inherits.  For example if "PlugInImageSubmit" inherits from "PlugInGeneric" it can be reached in the GUI via selecting Plugins->Generic->PlugInImageSubmit within the GUI. This page describes an '''optional''' method that allows you to modify that structure.
Algorithm that adds, subtracts, multiplies, or divides an image by some user specified value. In addition, the square root, absolute value, or log of an image can be calculated. If the new image exceeds the range that can be stored in an image of that type, the data is either clipped and stored in the original image or a new image of a type (int, float...) that can store the range of new data is generated.<br />


== Creating a Category ==
== Image types ==
You can apply Image Calculator to all 2D and 3D grayscale images. And here is the difference between Image Math and Image Calculator (refer to "Image Calculator"). The last one you can ally to all types of images 2D, 3D, 4D color and grayscale.<br />


Each plugin's location in the GUI is actually determined by the following field defined in every interface that is an instance of PlugIn.java:
== Applying the Image Math to images ==


<pre>
To run this algorithm, complete the following steps:
public static final String[] CATEGORY = {"Heading 1", "Heading 2",...,"Heading n"};
1 Open an image of interest.<br />
</pre>
2 Select Utilities &gt;Image Math. The dialog box opens. See Figure 39.<br />
3 Use the Operator list box to select the math operator (Absolute value, Add, Average, etc.).<br />
4 Use the Value text box to enter a numerical value.<br />
5 Select the Clip option if you want to clamp result data to the bounds of the input image type. Select the Promote option to promote image type so that the range of the result fits into the new image type. Select the Convert to Float option to convert the result into float image type.<br />
6 Click OK. The algorithm begins to run.<br />
7 Depending on whether you selected New Image or Replace Image, the result appears in a new window or replaces the image to which the algorithm was applied. See also Figure 39.<br />


Modifying this location requires the following.  In your plugin class that inherits a sub-interface of PlugIn (such as PlugInAlgorithm, PlugInGeneric, PlugInFile, etc.), add the public static final String array named CATEGORY (case sensitive).  Specify the hierarchical structure of your plugin's location using these headings. 


=== Plugins that inherit PlugInAlgorithm ===
{| border="1" cellpadding="5"
|+ '''Figure 39. The Image Math dialog box options '''
|-
|
<div class="CellHeading">Value</div>
|
<div class="CellBody">Enter the numerical value here. Note that the text box become available after you select the math operator.</div>
| rowspan="3" colspan="1" |
[[Image:ImageMathDialogBox.jpg]]
|-
|
<div class="CellHeading">Operator</div>
|
<div class="CellBody">Select the math operator from the list.</div>
|-
|
<div class="CellHeading">Clip</div>
|
<div class="CellBody">Select this option if you want the result image to be clamped at the maximum (minimum) value of the original image data type. </div>
|-
|
<div class="CellHeading"> </div>
| rowspan="1" colspan="2" |
<div class="CellBody">See also "clip mode".</div>
|-
|
<div class="CellHeading">Promote image type</div>
| rowspan="1" colspan="2" |
<div class="CellBody">When this mode is selected and the result value is out of the legal range of the original image data type, then the result image type is promoted to a new data type with a data type range capable of expressing the minimum and maximum values. See also "promotion mode".</div>
|-
|
<div class="CellHeading">Convert to float</div>
| rowspan="1" colspan="2" |
<div class="CellBody">When this mode is selected and the result value is out of the legal range of the original image data type, then the result image type is converted to float data type.</div>
|-
| rowspan="1" colspan="3" |
<div class="CellHeading">Destination</div>
|-
|
<div class="CellHeading">New image</div>
| rowspan="1" colspan="2" |
<div class="CellBody">The result image will open in a new image frame.</div>
|-
|
<div class="CellHeading">Replace image</div>
| rowspan="1" colspan="2" |
<div class="CellBody">The result image will replace the original image.</div>
|-
| rowspan="1" colspan="3" |
<div class="CellHeading">Process</div>
|-
|
<div class="CellHeading">Whole image</div>
| rowspan="1" colspan="2" |
<div class="CellBody">The algorithm applies to the selected VOI(s) region.</div>
|-
|
<div class="CellHeading">VOI region</div>
| rowspan="1" colspan="2" |
<div class="CellBody">The algorithm applies to the whole image.</div>
|-
|
<div class="CellHeading">OK</div>
| rowspan="1" colspan="2" |
<div class="CellBody">Applies the algorithm according to the specifications in this dialog box. </div>
|-
|
<div class="CellHeading">Advanced</div>
| rowspan="1" colspan="2" |
<div class="CellBody">Calls the Enter Advanced Operator dialog box.</div>
|-
|
<div class="CellHeading">Cancel</div>
| rowspan="1" colspan="2" |
<div class="CellBody">Disregards any changes that you made in this dialog box and closes it.</div>
|-
|
<div class="CellHeading">Help</div>
| rowspan="1" colspan="2" |
<div class="CellBody">Displays online help for this dialog box.</div>
|}


Note that no matter the structure specified, plugins that inherit from PlugInAlgorithm will not be displayed until an image is loaded.  If this condition means one of your specified GUI headings is left empty, that heading will not be displayed.  Once an image is loaded, these PlugInAlgorithms with their respective headings will be displayed.


== Example ==
==== Examples of using Image Math ====


===As PlugInGeneric===
{| border="1" cellpadding="5"
|+ '''Figure 40. Applying Image Math to images '''
|-
|
[[Image:ImageMathOriginal.jpg]]
|
[[Image:ImageMathAbsoluteValue.jpg]]
<br /><div class="CellBody">Absolute value</div>
|-
|
[[Image:ImageMathAdd100.jpg]]
<br /><div class="CellBody">Add 100</div>
|
[[Image:ImageMathAverage.jpg]]
<br /><div class="CellBody">Average</div>
|-
|
[[Image:ImageMathConstantToVOI.jpg]]
<br /><div class="CellBody">Constant</div>
|
[[Image:ImageMathDivideBy100.jpg]]
<br /><div class="CellBody">Divide by 100</div>
|-
|
[[Image:ImageMathLog.jpg]]
<br /> <div class="CellBody">Log</div>
|
[[Image:ImageMathMultilyBy5.jpg]]
<br /><div class="CellBody">Multiply by 5</div>
|-
|
[[Image:ImageMathSamplesSquare.jpg]]
<br /><div class="CellBody">Square</div>
|
[[Image:ImageMathSquareRoot.jpg]]
<br /><div class="CellBody">Square root</div>
|-
|
[[Image:ImageMathSubtract5.jpg]]
<br /><div class="CellBody">Subtract 5</div>
|
[[Image:ImageMathSum.jpg]]
<br /><div class="CellBody">Sum</div>
|}


If you haven't already tried to [[Writing MIPAV plugins without access to MIPAV source code|write MIPAV plugins without access to MIPAV source code]], start there.  Once you're set up in Eclipse (or whatever IDE suits you), try the following code in a new PlugInDNAStruct.java:
== See also: ==


<pre>
[[Inverting the image]]
import gov.nih.mipav.plugins.PlugInGeneric;
 
public class PlugInDNAStruct implements PlugInGeneric {
 
public static final String[] CATEGORY = {"NHGRI", "Watson", "Gene info"};
 
public void run() {
System.out.println("Guanine<->Cytosine, Adenine<->Thymine");
}
}
</pre>
 
Now install this plugin.  If you're using Eclipse, the associated .class file will be wherever your output path is (mipav/classes or mipav/bin most likely).  Once installed, you'll notice you can now navigate to Plugins->NHGRI->Watson->Gene info->PlugInDNAStruct, which prints out the above text.
 
===As PlugInAlgorithm===
 
Again learning how to [[Writing MIPAV plugins without access to MIPAV source code|write MIPAV plugins without access to MIPAV source code]] is a good starting point.  Create a PlugInInfluenzaStruct.java with the following code:
<pre>
import java.awt.Frame;
 
import gov.nih.mipav.model.structures.ModelImage;
import gov.nih.mipav.plugins.PlugInAlgorithm;
 
public class PlugInInfluenzaStruct implements PlugInAlgorithm {
 
public static final String[] CATEGORY = {"NIAID", "GenBank"};
public void run(Frame parentFrame, ModelImage image) {
System.out.println("Symptoms of flu include fever (usually high), headache, and extreme tiredness");
}
 
}
</pre>
Try installing this plugin without loading an image.  You'll see that the structure of the plugin GUI has not changed.  Load an image, and you'll notice that you can now navigate to Plugins->NIAID->GenBank->PlugInInfluenzaStruct.  The above text will be printed as standard output (in Eclipse this shows up in the console window).
 
==Closing Notes==
If you've installed a plugin whose directory location within the GUI you'd like to change, you '''don't''' need to re-install the plugin.  Like any change to the plugin, a change to the CATEGORY field will show up once you complile the plugin file.
 
Finally, this method is completely optional.  Plugins may continue to be developed without adding a CATEGORY field.


[[Category:Help]]
[[Category:Help]]

Latest revision as of 16:28, 9 February 2024

Algorithm that adds, subtracts, multiplies, or divides an image by some user specified value. In addition, the square root, absolute value, or log of an image can be calculated. If the new image exceeds the range that can be stored in an image of that type, the data is either clipped and stored in the original image or a new image of a type (int, float...) that can store the range of new data is generated.

Image types

You can apply Image Calculator to all 2D and 3D grayscale images. And here is the difference between Image Math and Image Calculator (refer to "Image Calculator"). The last one you can ally to all types of images 2D, 3D, 4D color and grayscale.

Applying the Image Math to images

To run this algorithm, complete the following steps: 1 Open an image of interest.
2 Select Utilities >Image Math. The dialog box opens. See Figure 39.
3 Use the Operator list box to select the math operator (Absolute value, Add, Average, etc.).
4 Use the Value text box to enter a numerical value.
5 Select the Clip option if you want to clamp result data to the bounds of the input image type. Select the Promote option to promote image type so that the range of the result fits into the new image type. Select the Convert to Float option to convert the result into float image type.
6 Click OK. The algorithm begins to run.
7 Depending on whether you selected New Image or Replace Image, the result appears in a new window or replaces the image to which the algorithm was applied. See also Figure 39.


Figure 39. The Image Math dialog box options
Value
Enter the numerical value here. Note that the text box become available after you select the math operator.

ImageMathDialogBox.jpg

Operator
Select the math operator from the list.
Clip
Select this option if you want the result image to be clamped at the maximum (minimum) value of the original image data type.
See also "clip mode".
Promote image type
When this mode is selected and the result value is out of the legal range of the original image data type, then the result image type is promoted to a new data type with a data type range capable of expressing the minimum and maximum values. See also "promotion mode".
Convert to float
When this mode is selected and the result value is out of the legal range of the original image data type, then the result image type is converted to float data type.
Destination
New image
The result image will open in a new image frame.
Replace image
The result image will replace the original image.
Process
Whole image
The algorithm applies to the selected VOI(s) region.
VOI region
The algorithm applies to the whole image.
OK
Applies the algorithm according to the specifications in this dialog box.
Advanced
Calls the Enter Advanced Operator dialog box.
Cancel
Disregards any changes that you made in this dialog box and closes it.
Help
Displays online help for this dialog box.


Examples of using Image Math

Figure 40. Applying Image Math to images

ImageMathOriginal.jpg

ImageMathAbsoluteValue.jpg


Absolute value

ImageMathAdd100.jpg


Add 100

ImageMathAverage.jpg


Average

ImageMathConstantToVOI.jpg


Constant

ImageMathDivideBy100.jpg


Divide by 100

ImageMathLog.jpg


Log

ImageMathMultilyBy5.jpg


Multiply by 5

ImageMathSamplesSquare.jpg


Square

ImageMathSquareRoot.jpg


Square root

ImageMathSubtract5.jpg


Subtract 5

ImageMathSum.jpg


Sum

See also:

Inverting the image