Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 25th March 2009, 09:45   #1  |  Link
Vitaliy Gorbatenko
viterra
 
Join Date: Feb 2003
Location: St. Peterburg, Russia
Posts: 142
How to make a mask only on the black lines?

If possible - how to do it? All that I try or too sensitive and mask not only the dark lines and color transitions, or not enough sensitive and did not see the black lines on dark colors.

The best was:
mt_edge(mode="cartoon", thY1=8,thY2=8,thC1=8,thC2=8)
But it mask color transitions too(blue to yellow 3.jpg)

Attached Images
  
Vitaliy Gorbatenko is offline   Reply With Quote
Old 25th March 2009, 14:33   #2  |  Link
Sagekilla
x264aholic
 
Join Date: Jul 2007
Location: New York
Posts: 1,752
Add U=3, V=3 to that mt_edge line and I think it should be fine.
__________________
You can't call your encoding speed slow until you start measuring in seconds per frame.
Sagekilla is offline   Reply With Quote
Old 26th March 2009, 05:44   #3  |  Link
Vitaliy Gorbatenko
viterra
 
Join Date: Feb 2003
Location: St. Peterburg, Russia
Posts: 142
mt_edge(mode="cartoon", thY1=8,thY2=8,thC1=8,thC2=8, U=3, V=3)
Thank you, but this did not help at all T_T
Vitaliy Gorbatenko is offline   Reply With Quote
Old 29th March 2009, 06:11   #4  |  Link
Comatose
Registered User
 
Join Date: Dec 2007
Posts: 639
AFAIK FastLineDarkenMod attempts to mask only black lines, so take a look at it and see if you can steal that part of the script.
Comatose is offline   Reply With Quote
Old 30th March 2009, 05:16   #5  |  Link
Vitaliy Gorbatenko
viterra
 
Join Date: Feb 2003
Location: St. Peterburg, Russia
Posts: 142
I have looked in his direction, but the principle of FastLineMask other. Mask on the line in the right form, it is not built.

function GreyCenteredToMask(clip input) {
input.Levels(128, 1, 255, 0, 255, false)
one = last
input.Levels(0, 1, 128, 255, 0, false)
two = last
Overlay(one, two, mode="lighten")
}

function Camembert(clip input) {

input
SmoothUV(3,200,false)
Overlay(last, Blur(1).Blur(1), mode="difference")
Greycenteredtomask().greyscale()
Levels(0, 1, 115, 0, 255, false)
mask1 = last
Blur(1)
Levels(0, 0.4, 64, 0, 255, false)
mask = last
Blur(1).Blur(1)
Levels(0, 1, 30, 0, 255, false).Blur(1)
mask2 = last
#MaskedMerge(input, input.Unfilter(-20, -20), mask)
#MaskedMerge(last, input.Deen("a3d", 4, 15, 15, 20), mask)
#Overlay(last, input, mask=mask1, mode="darken", opacity=0.5)
#deblock ? MaskedMerge(Unsharpmask(100, 2, 0).SluttyBlindPP(quant=15, cpu2="xoxoxo"), last, mask2) \
# : MaskedMerge(Unsharpmask(50, 2, 0), last, mask2)
#cleanup ? Deen("a3d", 4, 3, 5, 10) : last
#MaskedMerge(Unsharpmask(50, 2, 0), last, mask2)
return (mask2)


I need something like the mask as the attached picture, but that would mask the color transitions not covered - the moon should not be masked. This mask comes with a script Camembert.
Attached Images
 
Vitaliy Gorbatenko is offline   Reply With Quote
Old 30th March 2009, 09:29   #6  |  Link
TheRyuu
warpsharpened
 
Join Date: Feb 2007
Posts: 787
Code:
#Typical sobel mask:
#LoadPlugin("mt_masktools.dll")
mt_edge("sobel",7,7,5,5).mt_inflate() 

#alternative one, not using sobel:
mt_edge("roberts",0,4,0,4).mt_inflate()
Both taken from AA script(s). Their purpose is to only mask the lines so they'll work for your purpose.

Another alternative way of making a mask, sometimes a better mask, I believe it's taken from LSF or something like that idk.
But in reality, when used in an AA script, the final result looks identical to a regular sobel mask (above) in nearly all cases.

Code:
logic(a.DEdgeMask(0,255,0,255,"5 10 5 0 0 0 -5 -10 -5", divisor=4,Y=3,U=3,V=3)
 \       ,a.DEdgeMask(0,255,0,255,"5 0 -5 10 0 -10 5 0 -5", divisor=4,Y=3,U=3,V=3)
 \       ,"max").greyscale().levels(0,0.8,128,0,255,false)

Last edited by TheRyuu; 30th March 2009 at 09:32.
TheRyuu is offline   Reply With Quote
Old 30th March 2009, 10:07   #7  |  Link
Vitaliy Gorbatenko
viterra
 
Join Date: Feb 2003
Location: St. Peterburg, Russia
Posts: 142
They are all loosely related to color.
1.jpg - mt_edge ( "sobel", 7,7,5,5). Mt_inflate ()
2.jpg - mt_edge ( "roberts", 0,4,0,4). Mt_inflate ()
3.jpg - logic (clip.DEdgeMask (0,255 ...
The stronger the inverted color - the stronger will be processed.
Maybe I want too much??
Attached Images
   
Vitaliy Gorbatenko is offline   Reply With Quote
Old 30th March 2009, 11:40   #8  |  Link
FuPP
TotalEclipseOfTheBrain
 
FuPP's Avatar
 
Join Date: Sep 2002
Posts: 347
Here is what I get using HybridFupp's algo (edges appear in red) : seems to be less sensitive to color transitions...

FuPP
Attached Images
 
FuPP is offline   Reply With Quote
Old 30th March 2009, 13:50   #9  |  Link
Vitaliy Gorbatenko
viterra
 
Join Date: Feb 2003
Location: St. Peterburg, Russia
Posts: 142
Thank you for your advice. I have tested this mask too, but it has a serious flaw - a small sensitivity. The increase in sensitivity will lead to the capture of colors, too.
mask is very simple ..
mt_makediff(i.blur(1.58).blur(1.58), i).mt_binarize(threshold = trh).mt_inflate().mt_inflate()
Vitaliy Gorbatenko is offline   Reply With Quote
Old 30th March 2009, 14:20   #10  |  Link
Sagekilla
x264aholic
 
Join Date: Jul 2007
Location: New York
Posts: 1,752
You could try thresholding it against the luminance levels. You can say that, if luma < 30 then it's a black line: mt_lutxy(source, mask, "x 128 - abs "+string(thr)+" < y 0 ?")

That's quite a bit slower than just doing a simple edge detect mask, but it could give you the results you need.

@Vitaliy: Please upload your images to somewhere like imageshack. That way we can see them immediately without having to wait for a moderator to approve the attachments. I know neuron2 is usually very good with this, but it helps if we can see it right away instead of having any delay.
__________________
You can't call your encoding speed slow until you start measuring in seconds per frame.

Last edited by Sagekilla; 30th March 2009 at 14:31.
Sagekilla is offline   Reply With Quote
Old 30th March 2009, 16:49   #11  |  Link
FuPP
TotalEclipseOfTheBrain
 
FuPP's Avatar
 
Join Date: Sep 2002
Posts: 347
you can try something like this (same idea than Sagekilla).

Tested (on... 1 frame ) with e_th1 = 131, e_th2 = 135, e_th3 = 62


Function EM(clip i, int e_th1, int e_th2, int e_th3)
{
diff = mt_makediff(i.blur(1.58).blur(1.58),i)
a=diff.mt_binarize(threshold = e_th1).mt_inflate().mt_inflate()
b=diff.mt_binarize(threshold = e_th2).mt_inflate().mt_inflate()
c=i.mt_binarize(e_th3, upper=true)

return mt_logic(b,mt_logic(a,c,"and"),"or")
}

FuPP
Attached Images
 

Last edited by FuPP; 30th March 2009 at 16:55.
FuPP is offline   Reply With Quote
Old 31st March 2009, 05:50   #12  |  Link
Vitaliy Gorbatenko
viterra
 
Join Date: Feb 2003
Location: St. Peterburg, Russia
Posts: 142
Sagekilla: I am not much concerned about the speed of processing - the most important quality.

I do not know why, can severely distort the color jpg .. But the moon surrounded by little red. Inversion of the mask is well shown. Look at 60783903.jpg.
This code:
mt_lutxy(c, mask, "x 128 - abs "+string(threshold)+" < y 0 ?")
greatly reduces the sensitivity and do not protect against color transitions.


function LineMask( clip c, clip mask, int "threshold")
{
threshold = Default(threshold, 30)
linemask = mt_lutxy(c, mask, "x 128 - abs "+string(threshold)+" < y 0 ?")
return(linemask)
}


Function EM_FuPP(clip i, int "e_th1", int "e_th2", int "e_th3")
{
e_th1 = Default(e_th1, 131)
e_th2 = Default(e_th2, 135)
e_th3 = Default(e_th3, 62)

diff = mt_makediff(i.blur(1.58).blur(1.58),i)
a=diff.mt_binarize(threshold = e_th1).mt_inflate().mt_inflate()
b=diff.mt_binarize(threshold = e_th2).mt_inflate().mt_inflate()
c=i.mt_binarize(e_th3, upper=true)

return mt_logic(b,mt_logic(a,c,"and"),"or")
}

Function DR_Radius(clip i, int dr_rad, int count)
{
return count > dr_rad ? i : DR_Radius(i.mt_expand(), dr_rad, count+1)
}

Function DeHaloH(clip input, int "DR_Radius", int "DR_Str", bool "Maska")
{
Maska = Default(Maska, false)
EM=input.EM_FuPP()
# EM=LineMask(input, EM)
RM=DR_Radius(EM,DR_Radius,0)
DeRinging = input.Deen("a2d", 2, DR_Str , 0, 0, 0, 0, 0)
DeRinging = Maska ? DeRinging.Invert() : DeRinging
return mt_Merge(input, DeRinging, RM)
}

Call:
DeHaloH(2, 15, Maska=true)
Attached Images
 
Vitaliy Gorbatenko is offline   Reply With Quote
Old 31st March 2009, 19:43   #13  |  Link
TheRyuu
warpsharpened
 
Join Date: Feb 2007
Posts: 787
I'm not sure if this was said earlier, but what are you going to do with this mask?
TheRyuu is offline   Reply With Quote
Old 1st April 2009, 04:37   #14  |  Link
Vitaliy Gorbatenko
viterra
 
Join Date: Feb 2003
Location: St. Peterburg, Russia
Posts: 142
I want to clear the picture only in black lines. Distortion (wave effect) are visible only around them. And I do not want to touch the rest of the picture. To save the basic details.

Therefore, the logic of using mt_binarize not suitable. Too heavy processing removes detail.

Last edited by Vitaliy Gorbatenko; 1st April 2009 at 06:46.
Vitaliy Gorbatenko is offline   Reply With Quote
Old 9th April 2009, 08:31   #15  |  Link
Vitaliy Gorbatenko
viterra
 
Join Date: Feb 2003
Location: St. Peterburg, Russia
Posts: 142
It seems there is no proper solution to this problem. I stopped at this version of the script. (attached file) The script cleans well distortion (wave effect) on a light background, and not touch the dark parts (leaves the illusion of detail).
The best result for the use Tsukuyomi, I received the following call:

import ( "DeHaloH.avsi")

DeHaloH (2, 10, Maska = false)
LSFmod (ss_x = 1.5, ss_y = 1.5, smode = 3, strength = 125, overshoot = 1, undershoot = 1)
FastLineDarkenMOD (thinning = 0)
DeHaloH (2, 10, Maska = false)

Yes, the call made on two occasions. Perhaps there is a better option, but I do not know.

I used parts of the script: by mf - Camembert-v0.1.avs, HQDering-v0.1.avs; by FuPP - HybridFuPP_0.984a.avs.
Attached Files
File Type: zip DeHaloH.zip (874 Bytes, 166 views)
Vitaliy Gorbatenko is offline   Reply With Quote
Old 31st March 2014, 16:31   #16  |  Link
real.finder
Registered User
 
Join Date: Jan 2012
Location: Mesopotamia
Posts: 2,587
hi, I make some modifications to the DeHaloH

1 - Make mask works on black line as much as possible
and apply mask once more in the opposite way to keep the lines as they are ,and applied it only around them

2 - TBilateral is used instead of deen, DeHaloH function stay as it, and new one with these change is DeHaloHmod

3 - DR_Radius and other setting changed in name, and Radius now 4 which roughly equivalent 2 in old DeHaloH

may there are others, but I don't remember them now

-------

edit: for 22 10 2015 you can use it with an external dehalo filter like this DeHaloHmod(exdehalo="BlindDeHalo3(4,4)")

download (those old versions, go to this post for the last version)

DeHaloHmod 30 10 2014 http://pastebin.com/GhVpsids

and old one in Attachments

DeHaloHmod 22 10 2015 http://pastebin.com/D6M00iYG and in Attachments

DeHaloHmod 09 05 2016 http://pastebin.com/KkuiDtiK and in Attachments

DeHaloHmod 22 06 2016 http://pastebin.com/g3mjezVA

DeHaloHmod 07 10 2016 http://pastebin.com/4xv7u9te

DeHaloHmod 11 11 2016 http://pastebin.com/tA7aHtYP

DeHaloHmod 30 01 2017 (2.3) http://pastebin.com/bMQuP8v8 and in Attachments

DeHaloHmod 31 03 2017 (2.35) https://pastebin.com/gAFwi5kN and in Attachments
Attached Files
File Type: zip DeHaloHmod 31 3 2014.zip (1.4 KB, 211 views)
File Type: zip DeHaloHmod 22 10 2015.zip (1.5 KB, 121 views)
File Type: zip DeHaloHmod 09 05 2016.zip (1.7 KB, 80 views)
File Type: zip DeHaloHmod v2.3.zip (2.3 KB, 83 views)
File Type: zip DeHaloHmod v2.35.zip (2.7 KB, 217 views)
__________________
See My Avisynth Stuff

Last edited by real.finder; 26th August 2019 at 20:03. Reason: new ver.
real.finder is offline   Reply With Quote
Old 8th June 2015, 14:43   #17  |  Link
luquinhas0021
The image enthusyast
 
Join Date: Mar 2015
Location: Brazil
Posts: 270
I'm sorry if I didn't see, but you've tried to convert the original image into black and white, before you apply edge mask? If not, try it and post the results, please. Is edge mask the same of edge detection?
luquinhas0021 is offline   Reply With Quote
Old 19th June 2017, 05:28   #18  |  Link
real.finder
Registered User
 
Join Date: Jan 2012
Location: Mesopotamia
Posts: 2,587
new ver.

added extlmask and RadInflate

DeHaloHmod 2.37 https://pastebin.com/uSmZqapf and in Attachments

some edit in mask

DeHaloHmod 2.39 https://pastebin.com/nQr7trcn

DeHaloHmod 2.40 https://pastebin.com/pCXGRNGh and in Attachments

DeHaloHmod 2.41 https://pastebin.com/03mpGr70 and in Attachments

DeHaloHmod 2.43 https://pastebin.com/whb85Vyi and in Attachments
Attached Files
File Type: zip DeHaloHmod v2.37.zip (2.8 KB, 43 views)
File Type: zip DeHaloHmod v2.38.zip (2.9 KB, 63 views)
File Type: zip DeHaloHmod v2.40.zip (3.0 KB, 48 views)
File Type: zip DeHaloHmod v2.41.zip (3.0 KB, 58 views)
File Type: zip DeHaloHmod v2.43.zip (3.0 KB, 87 views)
__________________
See My Avisynth Stuff

Last edited by real.finder; 22nd July 2019 at 04:50.
real.finder is offline   Reply With Quote
Old 2nd August 2017, 16:56   #19  |  Link
gaak
Registered User
 
Join Date: Apr 2016
Posts: 27
What are the settings for mode?

@real.finder

Could you please tell me what the options are for mode? I can't find them documented anywhere.

Thanks.
gaak is offline   Reply With Quote
Old 17th August 2017, 17:34   #20  |  Link
real.finder
Registered User
 
Join Date: Jan 2012
Location: Mesopotamia
Posts: 2,587
Quote:
Originally Posted by gaak View Post
@real.finder

Could you please tell me what the options are for mode? I can't find them documented anywhere.

Thanks.
sorry for late, cuz I didn't note your post until now

but it's hard to explained mode options as I am not good in English

anyway mode for masking method, mode 0 mean it will use either Camembert_dhh() or Camembert_dhhmod() depending on strong parameter

from mode 1 and up see EMask_dhh Function
__________________
See My Avisynth Stuff
real.finder is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 17:32.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.