Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature request] mt_hysteresis2 #23

Closed
Purfview opened this issue Oct 23, 2021 · 18 comments
Closed

[Feature request] mt_hysteresis2 #23

Purfview opened this issue Oct 23, 2021 · 18 comments

Comments

@Purfview
Copy link

Would it be possible to make hysteresis2 func which would ignore the corner connections?

For example a mask with a single square wouldn't grow into the both squares:

alt text

@pinterf
Copy link
Owner

pinterf commented Oct 25, 2021

Need more info, because I'm quite unfamiliar - never used - with hysteresis. For example I didn't know that it has anything with corner connections. So because I'm dummy, and do not understand the request, other examples needed for me:

  • what does it mean: when a mask grows into something.
  • script with the behaviour which is not quite good.
  • is that figure is showing an expected behaviour?

@Purfview
Copy link
Author

Purfview commented Oct 25, 2021

This example should answer your questions:

mask1:
alt text

mask2:
alt text

maskH (result of hysteresis / mask1 grows into -> mask2 / result not good for me):
alt text

Expected result if the corner connections are ignored:
alt text

Script:

mask1=ImageReader(file="D:\mask1.png", pixel_type="Y8")
mask2=ImageReader(file="D:\mask2.png", pixel_type="Y8")
maskH=mask1.mt_hysteresis(mask2)

Stackvertical(mask1, mask2.AddBorders(0,2,0,0,$FFFFFF), maskH.AddBorders(0,2,0,0,$FFFFFF))

@Purfview
Copy link
Author

Forgot one scenario:

mask2:
alt text

In expected result that bottom square would disappear.

@Blankmedia1
Copy link

That's a good idea.

@pinterf
Copy link
Owner

pinterf commented Nov 15, 2021

Request registered, I busy with other projects at the moment, pls. ping me if no progress is made in a month, thanks :)

@Purfview
Copy link
Author

Request registered, I busy with other projects at the moment, pls. ping me if no progress is made in a month, thanks :)

Ping, ping... :)

@pinterf
Copy link
Owner

pinterf commented Feb 16, 2022

Yikes! It's time to remember :)

@pinterf
Copy link
Owner

pinterf commented Feb 17, 2022

Good news, I'm seeing the expected output in my tests. An additional parameter needed, perhaps 'corners'=true (default) and false for the new working mode? Or a better name?

@Purfview
Copy link
Author

Nice, no difference for me.

@pinterf
Copy link
Owner

pinterf commented Feb 18, 2022

Pls. check v30, if it is O.K. for you as well, then I release it.
https://drive.google.com/uc?export=download&id=1VjitVTdJNRw1mYFSJ5Ch3U30PGy3EZhX

@Purfview
Copy link
Author

It works as expected, just that corners=false is default in v30, should be other way around.

@pinterf
Copy link
Owner

pinterf commented Feb 19, 2022

@Purfview
Copy link
Author

Now default is correct.
I did some benchmarks, v30.test2 is faster than v30.test1, but it's ~10% slower than v29:

v29 ("corners=true") 4560

v30.test1 corners=false 4084
v30.test1 corners=true 3980

v30.test2 corners=false 4333
v30.test2 corners=true 4070

@pinterf
Copy link
Owner

pinterf commented Feb 19, 2022

Nothing has been changed in between. Since v29 Visual Studio 2019 got some months older.
Since test1 there has been zero changes.
Are you testing with the same type of dlls? (xp/nonxp/clang?) version?
EDIT: Anyway, I've rearranged some lines, and the new build regained speed of v29 for corners=true case.
I'm gonna upload a new set of dlls (build process of all versions takes ~25-30 minutes on my i7)

@Purfview
Copy link
Author

Purfview commented Feb 19, 2022

Strange, I ran dozens of times, results fluctuated around ~0.5%.

AVSMeter 3.0.7.0 (x86)
AviSynth+ 3.7.1 (r3556, master, i386)
dlls from "x86" folder
CPU supports AVX (no AVX2)

mask1:
alt text

mask2:
alt text

mask1=ImageReader(file="D:\mask1.png", pixel_type="Y8").loop(100)
mask2=ImageReader(file="D:\mask2.png", pixel_type="Y8").loop(100)
maskH=mask1.mt_hysteresis(mask2, corners=true)
maskH

@pinterf
Copy link
Owner

pinterf commented Feb 19, 2022

New v30 build
https://drive.google.com/uc?export=download&id=1-qYyGEqJci2RmDl5MLymkLZv07-dZuJE
EDIT: there is no SIMD acceleration inside. I was testing x64

@Purfview
Copy link
Author

Nice rearrangement, now it's even faster than v29:

v29 ("corners=true") 4560

v30.test1 corners=false 4084
v30.test1 corners=true 3980

v30.test2 corners=false 4333
v30.test2 corners=true 4070

v30.test3 corners=false 4854
v30.test3 corners=true 4680

@Purfview
Copy link
Author

Thank you.
Now I need to remember where and when I needed it and test it in the real world. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants