View Full Version : How to apply a sharpening through edge mask (Smart Sharpen) ?
lisztfr9
5th November 2012, 18:24
Hi,
I know there is a plugin from D. Graf , :
http://neuron2.net/msharpen/msharpen.html
But it's spatial sharpening imho.
With mt_edge one can build a stream of edge masks and soften it temporally, and then i dunno how to apply sharpening through that mask... certainly not with overlay. Any idea ? It's the same concept as in Gimp, the smart Sharpening effect but with temporal denoising the mask.
Also, do you run analyses on your videos, for ex luma, anything, and log it ? Then in the log file one could detect recurrences.
Thanks, L.
Ok, i think overlay can be used.
Bloax
5th November 2012, 18:45
Have you tried using the incredibly cryptic function included in MaskTools2 that only the highest standing among the Avisynth hermits know;
Mt_Merge(a,b,mask)?
lisztfr9
5th November 2012, 19:44
Have you tried using the incredibly cryptic function included in MaskTools2 that only the highest standing among the Avisynth hermits know;
Mt_Merge(a,b,mask)?
No, i leave that to true sorcerers like Didée & Cie, specially with RPN. For the sake of it i bought myself an HP 48G in order to practice :)
Mt_Merge, the "backbone" of masktools as they call it.
Mt_merge, that's right !
L
Didée
5th November 2012, 20:44
- build an edgemask
- prepare "source" and "sharpened source"
- merge together
vid = last # whateveryouhave as starting point
sharp = vid.sharpen(0.6)
emask = vid.mt_edge(mode="prewitt",thy0=0,thy1=255)
result = mt_merge(vid,sharp,emask, U=2,V=2)
return(result)
"prewitt" is an edgemasking mode that is quite robust against noise. Probably no need to run any temporal-cleaning for this mode.
In the mt_merge, only luma from the sharp-clip is merged onto the "vid" source clip. (In many cases, chroma sharpening is not really wanted, and/or not effective anyway.)
If you want to sharpen chroma nonetheless, change to
"mt_merge(vid,sharp,emask,luma=true,U=3,V=3)"
The "sharpen(0.6)" is only a simple example for sharpening. There's dozens or hundreds of different sharpening-scripts posted here on the forum.
The merging could be done with Overlay() instead of mt_merge, but .... mt_merge is fast, easy, straightforward. Overlay() is slow, has (too) many options, and I'm never sure if everything is set up correctly. ;)
lisztfr9
5th November 2012, 21:59
Thanks Didée, i would have try Sobel first because i was used to do so in Gimp. Also the habit was to apply a little amount of blur to the edge mask... so many things to take care of :)
L
manioxy
6th November 2012, 06:53
Open up the Unsharpen Mask dialog (Filter->Sharpen->Unsharpen Mask). Use a large amount (250-500%), you can get away with this because the effect is so targeted. Use a radius of 1.0 and a threshold of 2. Don't worry about the mess in the Preview screen of the USM dialog, that only shows you the underlying image (with no mask applied).
Sit back and enjoy the sharpness...
lisztfr9
23rd November 2012, 13:51
Hi Didée,
I'm trying your code from 5th November 2012 20:44
mt_edge(mode="prewitt",thy0=0,thy1=255)
correct imho :
mt_edge(mode="prewitt",thy1=0,thy2=255)#.Grayscale()
I wonder why sometimes i get a green frame and sometimes not. I could set it to greyscale, but this green seems related to no error so what does it mean ?
http://cjoint.com/12nv/BKxnSaSUOxj.htm
Thanks, L
Gavino
23rd November 2012, 14:57
I wonder why sometimes i get a green frame and sometimes not.
Are you trying to sharpen the chroma as well, following Didée's remark:
If you want to sharpen chroma nonetheless, change to
"mt_merge(vid,sharp,emask,luma=true,U=3,V=3)"
If so, (something Didée forgot to mention) you also need to change the mt_edge call to:
emask = mt_edge(mode="prewitt",thy1=0,thy2=255, U=3, V=3)
Didée
23rd November 2012, 15:05
Sorry but no, the call to mt_edge doesn't need U=3,V=3. There is no need for chroma edges in the edgemask. The mt_merge uses "luma=true", i.e. the luma edgemask is used also for the chroma planes. (It's often favourable to do so, because the "true" chroma "edges" often are too weak to derive a good edgemask from them.)
lisztfr9
23rd November 2012, 15:10
@Gavino
Thank you :) I wasn't trying to processes luma, so i set the U=2, V=2, now this kind of erratic green color disappears.
Gavino
23rd November 2012, 15:21
The mt_merge uses "luma=true"
Yes, sorry, I missed that bit (despite quoting it!).
@lisztfr9: I thought you were saying the final result was green, but I think now you just meant that the mask itself was green. That doesn't matter, since the chroma of the mask is not used, but if it bothers you (when examining the mask), then yes, you can get rid of it with U=2, V=2 in the mt_edge call.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.