Author V. C. Mohan
Last modified Date Aug 2014

Image enhancement is attempted by segmenting using Vincent Soille algorithm for watershed and basin delineation. In general watershed technique over-segments. To minimise this, the input may be preprocessed (denoised using DeNoise plugin and or blurred with function GaussBlur available in ColorIt plugin or frequency filtered with F2Quiver function of FFTQuiver or numerous other functions available for Avisynth) to reduce segmentation.

The pixel values within a basin are stretched and or shifted wrt the seed value which can be either highest or lowest within that basin. stretch and shift values can be linearly varied within the frame interval selected. By selecting suitable values of parameters an effect of finger painted image can be obtained. By Freezing a frame required length and using proper starting and ending stretch, shift values a transition from a painting to real or vice versa can be obtained.

All color formats supported by avisynth version are accepted. Stretching and shifting is done on all 3 color values of RGB formats. The criterion for limiting a basin can be all 3 colors independant or as logical AND . In case of YUY2 and YV12 Y values only are processed.

Details of parameters
Description Name Type Limits Default
Input clip clip none
start frame number sf integer within clip 0
end frame number ef integer not less than sf and within clip number of frames - 1
%age stretch st integer -100 to 100 1
%age shift sh integer -100 to 100 -1
nearest 4 or 8 to be used for connectivity connect4 boolean true for connect 4, false for connect 8 true
seed value to be used to fill? seed bool true for use lowest or highest value in each basin to fill. false calculate using seed and stretch and shift false
lowest value is seed? low bool true for use lowest value in each basin as seed. false use highest value as seed false
process independantly all 3 color values for RGB formats? separate bool true for processing colors separately. false all 3 color segments are processed using logical AND false

#Usage examples:-

retouch(img,separate = false, low = true,seed = false, st = -10, sh = 0)
retouch(img,sf = 20, ef = 30,separate = false, low = true,seed = false, st = -10, sh = 0, est = 10, esh = -5)
retouch(dn2,sf = 0, ef = 1,separate = false, low = true, seed = false, st = -100, sh = -30, est = 0, esh = 0)

below is an illustration of results. Left is input. Right is output script used:-
img =separatefields()
f2q = F2Quiver(img,"bvn",180,20, degree = 4)
dn2 = denoise( img,lx = 360, rx = 400, ty=230,by=280, clip = false)
retouch(dn2,separate = false, low = true,seed = false, st = -10)
# following for paint effect
#retouch(dn2,sf = 0, ef = 1,separate = false, low = true, seed = false, st = -100, sh = -30, est = 0, esh = 0)

noisy image

with paint effect
paint image

Following paint effects are with script:
retouch(separate = false, low = true, seed = true, st = -10)

To my index page To Avisynth