Log in

View Full Version : TCannyMod


Chikuzen
17th August 2013, 20:15
Canny edge detection filter (http://en.wikipedia.org/wiki/Canny_edge_detector) for Avisynth2.6x based on tcanny by tritical.

slow (because almost all processings are performed in the floating point), but faster than tcanny about 1400% to 2500%(by the favor of SSE/SSE2 and smart hysteresis algorithm).

binary: TCannyMod-1.2.0.zip (https://github.com/chikuzen/TCannyMod/releases)
source code: https://github.com/chikuzen/TCannyMod/

requirement:
* Avisynth2.6.0/Avisynth+r1576 or greater
* Microsoft Visual C++ 2015 Redistributable Package
* WindowsVista sp2/7 sp1/8.1/10
* SSE2 capable CPU

EDIT:
2016-05-25 update to 1.2.0

mastrboy
17th August 2013, 20:37
Canny edge detection filter (http://en.wikipedia.org/wiki/Canny_edge_detector) for Avisynth2.6x based on tcanny by tritical.

slow (because almost all processings are performed in the floating point.), but faster than tcanny about 1400% to 2000%(by the favor of SSE/SSE2).

binary: tcannymod-0.0.1.zip (http://www.mediafire.com/download/36gamn5a51coo56/tcannymod-0.0.1.zip)
source code: https://github.com/chikuzen/TCannyMod/

requirement:
* Avisynth2.6 alpha4 or later
* Microsoft Visual C++ 2010 Redistributable Package
* WindowsXPsp3/Vista/7/8
* SSE2 capable CPU

Nice :) , am I right if I'm guessing this as step 1, before porting this to [VapourSynth] GenericFilters ?

And more of a curiosity question, would this plugin be even faster if AVX optimization was added considering it's floating point heavy?

Chikuzen
17th August 2013, 20:51
Nice :) , am I right if I'm guessing this as step 1, before porting this to [VapourSynth] GenericFilters ?

yes.

And more of a curiosity question, would this plugin be even faster if AVX optimization was added considering it's floating point heavy?

Dunno.
My machine is old penlyn.

Mystery Keeper
18th August 2013, 00:10
Chikuzen, if in your VS project settings you deselect any runtime - your plugin will be linked against static runtime, eliminating dependency for the small size cost.

Chikuzen
18th August 2013, 02:42
Chikuzen, if in your VS project settings you deselect any runtime - your plugin will be linked against static runtime, eliminating dependency for the small size cost.

The reason I do not static link MSVCRT is for security and performance.
It is a foolish act to release a new binary whenever a bug is found in MSVCRT. The developer who likes static link is an irresponsible person who does not consider such a thing.
And in my experience, dynamic linked binaries are a bit faster than static linked.

LaTo
18th August 2013, 07:49
Dunno.
My machine is old penryn.

avxintrin-emu.h (http://software.intel.com/en-us/articles/intel-avx-cc-intrinsics-emulation)

I used this when I didn't have an AVX CPU.

Chikuzen
19th August 2013, 04:51
update to 0.1.0

* fix some typo
* add new function 'GBlur'
* add new argument 'sobel'
* sigma allows to set to 0 (do not blur before edge detection)

Chikuzen
21st August 2013, 02:59
update to 0.1.1

* fix crash when sigma is too large.

mawen1250
27th August 2013, 19:38
It seems using left Crop before TCannyMod will return error "TCannyMod: Invalid memory alignment".

This script returns error

BlankClip(1000, 1920, 1080, "YV12")
Crop(4, 0, 0, 0)
TCannyMod()

While this one works

BlankClip(1000, 1920, 1080, "YV12")
Crop(0, 4, -4, -4)
TCannyMod()

StainlessS
27th August 2013, 19:55
This script returns error

BlankClip(1000, 1920, 1080, "YV12")
Crop(4, 0, 0, 0)
TCannyMod()

Try

BlankClip(1000, 1920, 1080, "YV12")
Crop(4, 0, 0, 0,align=true)
TCannyMod()

Chikuzen
26th March 2016, 12:28
updated to v1.0.0

Chikuzen
27th March 2016, 19:40
update to 1.1.0.

blank000
3rd April 2016, 04:50
Hi Chikuzen
I question here.Avisynth wiki

EMask with default settings is
GBlur (sigma=1.5, gmmax=50.0, chroma=0, sobel=false, opt=-1)

Should this be corrected "EMask"

Chikuzen
3rd April 2016, 08:27
Hi Chikuzen
I question here.Avisynth wiki

EMask with default settings is
GBlur (sigma=1.5, gmmax=50.0, chroma=0, sobel=false, opt=-1)

Should this be corrected "EMask"

fixed:p

Chikuzen
25th May 2016, 10:19
update to 1.2.0

- Set filter mode as MT_NICE_FILTER automatically on Avisynth+ MT.
- Use buffer pool on Avisynth+ MT.
- Disable AVX2/FMA3/AVX code when /arch:AVX2 is not set.
- Disable AVX2/FMA3/AVX code on Avisynth2.6.

jpsdr
26th May 2016, 10:21
A little question about things like this in your code :

#if defined(_MSC_VER)
__cpuid(array, info_type);
#else
__cpuid(info_type, array[0], array[1], array[2], array[3]);
#endif

What compiler from VS are you switching from ?
Is it Intel compiler, or another ? In what case do you put the Intel compiler ?

:thanks:

Chikuzen
26th May 2016, 10:37
What compiler from VS are you switching from ?
Is it Intel compiler, or another ? In what case do you put the Intel compiler ?

It's GCC (and Clang).
That code was written to use it by vapoursynth plugins originally.
Since avisynth's GetCPUFlags() does not support AVX2 and FMA3, I use it on avisynth plugins too.

mp3dom
29th January 2017, 14:43
Don't know if this is the right place to post (or maybe in the avs+ topic?) but I get an "Avisynth open failure: system exception - access violation" when just loading the plugin (on latest dev avs+ r2397). The strange thing is that this happens only on x86 because the x64 version seems to work fine (at least it load the plugin).

kgrabs
30th January 2017, 06:38
actually i got an access violation too, after upgrading to Avisynth+r2172 MT i386 from Avisynth+r1576, that went away after i removed tcannymod.dll from my autoload folder

pinterf
30th January 2017, 17:58
I think the plugin uses IScriptEnvironment2 avs+ interface, that is avs+ version dependent, and has been changed since the last build

mp3dom
30th January 2017, 23:17
So it should be changed a little and then recompiled, I guess...?

ryrynz
18th February 2017, 10:46
I had a quick play with this for usage with Awarp4 but found that aSobel gave thinner lines. I was looking for something that provide improved edge detection.
Since I could find any options that gave me similar results, I suspect aSobel is optimized for Awarpsharp. Is it possible that anything here could be used to improve or give extra options to aSobel?

real.finder
18th February 2017, 13:18
Don't know if this is the right place to post (or maybe in the avs+ topic?) but I get an "Avisynth open failure: system exception - access violation" when just loading the plugin (on latest dev avs+ r2397). The strange thing is that this happens only on x86 because the x64 version seems to work fine (at least it load the plugin).

actually i got an access violation too, after upgrading to Avisynth+r2172 MT i386 from Avisynth+r1576, that went away after i removed tcannymod.dll from my autoload folder

there are already new build in https://github.com/chikuzen/TCannyMod/releases it work fine here

WolframRhodium
19th February 2017, 15:14
I had a quick play with this for usage with Awarp4 but found that aSobel gave thinner lines. I was looking for something that provide improved edge detection.
Since I could find any options that gave me similar results, I suspect aSobel is optimized for Awarpsharp. Is it possible that anything here could be used to improve or give extra options to aSobel?

I think aSobel() is an SIMD optimized filter whose internal procedure consists of mt_convolution() and mt_lutxy(), so one can modify it in .avs with similar stuff.

Reel.Deel
19th February 2017, 15:57
I think aSobel() is an SIMD optimized filter whose internal procedure consists of mt_convolution() and mt_lutxy(), so one can modify it in .avs with similar stuff.

Interesting, I've always wonders why the output of aSobel() differs from standard Sobel filters. Do you have an example of how this is done?

WolframRhodium
20th February 2017, 05:33
Interesting, I've always wonders why the output of aSobel() differs from standard Sobel filters. Do you have an example of how this is done?

Here's the code in vapoursynth-awarpsharp2 (https://github.com/dubhater/vapoursynth-awarpsharp2/blob/master/src/awarpsharp2.cpp#L25).

real.finder
22nd April 2017, 02:08
hi chikuzen

to avoid the collision, gblur in TCannyMod need to chose another function name cuz there are already GBlur by vcmohan

and CombMask in CombMask.dll too, CombMask already there in masktools1

ajp_anton
15th November 2022, 15:16
Is this supposed to support higher bitdepths? Because it seems utterly broken when fed higher than 8 bits, but on the other hand it doesn't reject it, it just silently produces garbage. Except if you're (un?)lucky and it just crashes, then you know something's wrong.

kedautinh12
15th November 2022, 15:20
Is this supposed to support higher bitdepths? Because it seems utterly broken when fed higher than 8 bits, but on the other hand it doesn't reject it, it just silently produces garbage. Except if you're (un?)lucky and it just crashes, then you know something's wrong.

Vapoursynth's backported was supported HBD
https://github.com/Asd-g/AviSynth-vsTCanny