SegAmp


Author V. C. Mohan
1 Oct 2020

Image enhancement is attempted by segmenting using Allen Soille algorithm for watershed and basin delineation. In general watershed technique over-segments. To minimise this, the input may be preprocessed (with minvar or GBlur functions of this plugin or other functions available for Avisynth+) to reduce segmentation.

This plugin smoothens within segments (basins) and or accentuates (sharpens) the segment boundaries to visually enhance the image. For RGB or Y plane of planar or YUY2 formats. sm is smoothening factor with values between 0 and 10. Sh is sharpening factor with value between -10 to 10. Both should not be simultaneously zero. sh values of -2 or so appears to yield better results.

Smoothenig is done on R,G,B and Y color and can also be done on u, v of YUY2 and Planar formats Sharpening is always limited to Y values.

Segmention can be done on the image of a different clip (sclip) and used for smoothing or sharpening. For instance, a blurred clip or denoised clip preferably be used as the sclip.

This function is Thread Safe. MT_NICE_FILTER
Details of parameters
Description Name Type Limits Default
Input clip clip none
sharpening factor for RGB or Y values sh integer -10 to 10, both sh and sm must not be 0 for RGB formats. Use small value. 2
smoothing factor for RGB or Y plane sm integer 0 to 10, both sh and sm must not be 0 for RGB formats 2
smoothing factor for U plane(for YUY and YUV only) smu integer 0 to 10 2
smoothing factor for v plane(for YUY and YUV only) smv integer 0 to 10 2
nearest 4 or 8 to be used for connectivity c4 boolean true for connect 4, false for connect 8 true
Use a different clip for segmenting? useclip bool true for use clip. false for segment and process same clip false
clip for segmenting if useclip is true sclip clip valid clip. Not the one at first parameter need not be specified if useclip is false

#Usage examples:-

dn = denoise(......)
SegAmp(dn, useclip = false,sh = 0, sm = 10 )
SegAmp(img, useclip = false,  sh = -5, sm = 0 )
inv1 = invert(dn)
SegAmp(img, useclip = true, sclip = inv1, sh =-1,sm = 10)
gb = gaussblur(img,size=5, sd = 3.5)
SegAmp(dn, useclip = true,sclip = gb, sh =-5, sm =4)


below are illustration of results. Top row are inputs. Left is the original image. Center is Gaussian blurred image. Right de noised with minvar image. Bottom row is the output using this plugin. script used for this output is:-

sh0 =SegAmp(gb, useclip = false, sh = -6, sm = 10, smu = 0, smv = 0 )
sh1=SegAmp(dn, useclip = false,  sh = -6, sm = 2 , smu = 0, smv = 0)
sh2=SegAmp(img, useclip = false, sh =0,sm = 10)
s1 = stackhorizontal(img,gb,dn)
s2 = stackhorizontal(sh2,sh0, sh1)
stackvertical(s1,s2)
To my index page down loadmanyPlus plugin To Avisynth