Indigo Ray
![]() |
I'm surprised I couldn't find an existing topic to put this in, although it was mentioned here...
I wrote a script (well, two) to find either the maximum or minimum RGB value for any input. Then, I used the max and min to find the average (*of the max and min, NOT of the whole image!) as well as the range (difference between max and min). Finally, I used the average and range to normalize the input (between 0=black and 1=white). Unfortunately, the min/max scripts are very slow and lag the interface. Each pixel of the input should be sampled only once, so I'm not sure why it takes so long. Any optimization ideas? There's also a slight inaccuracy of calculating the max/min. Why? Thanks ThreeDee for your histogram script, which helped me. (Requires FF5) Internal Normalize.ffxml |
|
Posted: December 4, 2015 12:36 pm | ||
Rachel Duim
![]() |
Take a look at this topic. There are known issues with scripting and inefficiency, and it looks like you've run in to it. I'm guessing large arrays in the init section.
Also, because caching is not completely implemented for map scripts (as far as I know), this can be an issue as well. An example of that issue would be the FXAA anti-aliasing script, which works very well as a standalone, but can't be included with most filters, it slows WAY down. My 2 cents. Math meets art meets psychedelia. |
|
Posted: December 4, 2015 3:11 pm | ||
Indigo Ray
![]() |
Thank you Rick. I thought prepare() was called once per render, but it seems it is called once per render block.
For a 600x600 image, there are 64 (8x8) blocks. In the case of the min/max scripts, that means that the minimum or maximum is calculated 64 times on one input, when it only needs to be calculated once! My one consolation is that my script will be a lot faster when (not if!) the FF team fixes this known problem. |
|
Posted: December 5, 2015 12:54 pm | ||
Sphinx.
![]() |
Prepare * Blocks * Passes (if you have multipass rendering enabled).. don't get your hopes upthat they will fix it - it has been there sooo long
![]() Anyways if you don't go for 100% exact result, you can use a combination of checkers, maximum/minimum and lookup to get a well performing solution |
|
Posted: December 6, 2015 3:43 pm | ||
Indigo Ray
![]() |
NOW I get your sig, Sphinx.
![]() Ok, I just tried that method. Works pretty well, thanks! I tried lowering the min/max radius and increasing the # of squares (samples), and then looping over the samples, but that made it MUCH slower. Why is it that the bitmap components, which are known to be slow, are suddenly the fastest method available? Caching? ![]() Note: attached is the method to find minimum. It takes 4 samples, but should really take 5x5 = 25 for best accuracy because the maximum radius of the Min/Max components is SIZE/5. But that's just too slow to be useful. Internal Min Faster.ffxml |
|
Posted: December 6, 2015 8:21 pm | ||
Sphinx.
![]() |
Here is how I thought they should be connected. I added a combined min/max chain that can find both min and max at the same time for grayscale sources.
Tweak the number of checkers and radius to adjust performance/precision Internal Min Faster.ffxml |
|
Posted: December 7, 2015 2:57 am |
Filter Forge has a thriving, vibrant, knowledgeable user community. Feel free to join us and have fun!
33,712 Registered Users
+18 new in 30 days!
153,537 Posts
+6 new in 7 days!
15,348 Topics
+72 new in year!
22 unregistered users.