2.6.3.4 imgMorph(Pro)
Contents
Menu Information
Image: Arithmetic Transform: Morphological Filter
Brief Information
Apply morphological filter to matrix or image
Additional Information
This feature is for OriginPro only.
Command Line Usage
1. imgMorph op:=open emode:=diamond r:=5;
2. imgMorph op:=erosion emode:=rec col:=5 row:=4;
X-Function Execution Options
Please refer to the page for additional option switches when accessing the x-function from script
Variables
| Display Name |
Variable Name |
I/O and Type |
Default Value |
Description |
|---|---|---|---|---|
| Input Image | im |
Input MatrixObject |
|
Specifies the input image, which should be a numeric matrix, a grayscale image or a binary image. The default input is the active image. |
| Output Image | om |
Output MatrixObject |
|
Specifies the output image. By default, a new image will be created and used as output. See the syntax here. |
| Operation | op |
Input int |
|
Specifies the morphological operation to perform.
|
| Flat Element | flat |
Input int |
|
Specifies whether or not to use a flat structuring element. |
| Height Matrix | hm |
Input MatrixObject |
|
This variable is available only when Flat Element is set to 0. It specifies the matrix that has the heights of the structuring element. |
| Create Element | emode |
Input int |
|
Specifies the structuring element.
|
| Element Matrix | em |
Input/Output MatrixObject |
|
This variable is available only when the Create Element variable is set to Arbitrary. You can use it to specify a matrix object that represents the structuring element. |
| Column | col |
Input int |
|
This variable is available only when the Create Element variable is set to Rectangle. It specifies the width of the rectangle. |
| Row | row |
Input int |
|
This variable is available only when the Create Element variable is set to Rectangle. It specifies the height of the rectangle. |
| Width | w |
Input int |
|
This variable is available only when the Create Element variable is set to Square. It specifies the width of the square. |
| Radius | r |
Input int |
|
This variable is available only when the Create Element variable is set to either Diamond or Octagon. It specifies the radius of the structuring object. |
| Row Offset | roffset |
Input int |
|
This variable is available only when the Create Element variable is set to either Periodicline or Pair. It specifies the row offset between two adjacent members. |
| Column Offset | coffset |
Input int |
|
This variable is available only when the Create Element variable is set to either Periodicline or Pair. It specifies the column offset between two adjacent members. |
| Length | len |
Input int |
|
This variable is available only when the Create Element variable is set to line. It specifies the length of the line object. |
| Angle (in degrees) | deg |
Input int |
|
This variable is available only when the Create Element variable is set to line. It specifies the angle for the line object. The unit is degree. |
| Points in One Side | np |
Input int |
|
This variable is available only when the Create Element variable is set to Periodicline. It specifies a number p. And then, there will be 2*p+1 dots in the structuring element. |
Description
Examples
In this example, the input image contains several square objects with different sizes. We use the imgMorph X-Function to remove the small objects from it. The procedure is as follows:
- Create a new matrix and imports the image file into it.
- When the image is active, select Image: Arithmetic Transform: Morphological Filter from the menu to open the dialog of the X-Function.
- In the X-Function dialog, change the settings as the screenshot below and click OK
to close the dialog.
The output image and the structure elements are created. We can see that the output image only has large squares.
Structuring Element
Note: OriginPro includes the ability to automatically recalculate the analysis result of the Morphological Filter operation any time you change the parameters or update your source data. In addition, the settings for the analysis routine can be saved to an analysis theme for later use with similar data.
Algorithm
To perform morphological filter on the input image, the structuring element is passed over the image. Let B be the input image and S be the structuring element. We denote by Sxy the translated structuring element whose origin is located at the point (x,y).
The output for erosion can be expressed as follows:
And the output for dilation is:
where
is reflection of set S, is defined as
Open operation is carried out by performing erosion once and then dilation once. And closing is carried out by performing dilation once and then erosion once.
References
Kenneth R.Castleman.1996. Digital Image Processing. Prentice Hall, Upper Saddle River, NJ, USA.






