Morph


Author V. C. Mohan
Date 1 Oct 2020
All my plugins are available for free download from "here".

Using morphology princeples the image is modified by "dilate" or "erode" or "close" or "open" procedures. This function can also do a median filtering. A 3x3 structural element is used. erode or dilate procedures can be repeated several times to get the effect of a larger structural element. .

Several structural elements are built in and used by setting str = "square", or "plus" or "x" or "y" or "z' or "H" or "-" or "l" or "l45" or "l135". If str = "file" is specified then the definition of the structural element will be as given in a text file

If file is opted then parameter file = "full path with name of text file" must be specified. Text file first entry must be string structure. Second entry must be number of x and y relative coordinate pairs. A maximum of 15 pairs of values can be specified. Ensure that coordinates are not repeated and origin 0 0 is included in file as one of the pairs. Also be aware that as the size of structure increases that more and more border pixels may not be processed.

The input color formats are YUY2, YUV 8 to 32 bit depths. This function operates on Luma plane and so RGB formats are not accepted.

It will be preferable to remove impulsive noise ( salt and pepper) prior to input for all options except median. Median filter it self removes impulsive noise, so it can be used as a preprocessor..

It is thread safe MT_NICE_FILTER
Details of parameters
Description Name Type Limits Default
Input clip clip none
Type of process opted opt string "dilate", "erode", "open", "close", "median" "dilate"
number of iterations iter integer 1 to 6. Applicable for dilate and erode options only 1
structural element opted str string "square", "plus", "x", "y", "z" , "-", "l", "H", or "file" "square"
filename file string "valid file name with full path" none. For str = "file" must be specified

Usage examples

# pre process to filter impulsive noise
Morph(opt = "median")
# dilate repeated 2 times
Morph(opt = "dilate", iter = 2)
Example: Top left Dilate, right : erode, Bottom left : open, Right: close.
sample file option and file :
morph(opt = "median", iter = 1, str = "file", file = "C:\avsfiles\structure.txt")
structure
11
-2 2
-2 1
-2 0
-2 -1
-2 -2
-1 -2
-1 -1
-1 0
-1 1
-1 2
0	0
To my index page down loadmanyPlus plugin To Avisynth