YOUR ACCOUNT

Login or Register to post new topics or replies
tigerAspect
Posts: 222
Filters: 9
Mostly a request, and also a shoutout to Sphinx who may have cracked this already. smile;)

What is it? Basically, you take a binary image (black/white), say that white defines the shape, for each white pixel, you give it a value that is it's distance to the nearest non-white pixel.

Ideally, a solution could be found that used a choice of whatever distance metric you wanted, like Euclidean, Manhattan or Chessboard distances.

Why? This surprisingly simple mathematical operation is the basis for the hallowed "Bevel/Emboss" layer style in photoshop, which is itself the basis for a whole world of graphical design techniques.
  Details E-Mail
Crapadilla
lvl 52 Filter Weaver and Official "Filter Forge Seer"

Posts: 4365
Filters: 65
Sounds as if this could be possible in the form of a bitmap-based component.

+1
--- Crapadilla says: "Damn you, stupid redundant feature requests!" ;)
  Details E-Mail
Sphinx.
Filter Optimizer

Posts: 1750
Filters: 39
Yes, I did solve this, but the filter is not very generic - it currently relies on a certain image size to work properly. I'm hoping for FF to add more control logic for gray properties so I can control radius settings in relation to pixel "size". I know a way to work out the pixel/percentage ratio, but I can't connect the result to radius properties (green don't mix with gray props). It would be awesome if they added a sampled "control", i.e. a gray module that takes one sample from a green sampler source and use that for the grey constant output.
  Details E-Mail
CorvusCroax
CorvusCroax

Posts: 1227
Filters: 18
I agree, this would be enormously useful. +1! This would be a good green component (or RGB math component)

Sphinx, would you mind posting the snippet, for the sake of demonstration?

I'm sure that a lot of people would like to use it, even with the limitations. (including me smile:D )



  Details E-Mail
Sphinx.
Filter Optimizer

Posts: 1750
Filters: 39
Alright, here you go. Minimum radius and threshold clipping settings are relative to image size. The filter was designed for 600x600 px, other sizes might result in wrong intensity steps etc.





Distance.ffxml
  Details E-Mail
CorvusCroax
CorvusCroax

Posts: 1227
Filters: 18
Ah, I see why you can't generalize it. You're doing it in steps. Interesting...
  Details E-Mail
Sphinx.
Filter Optimizer

Posts: 1750
Filters: 39
Yes exactly. Basically what is going on is this:

We take the initial binary shape and multiply it with a small value to avoid running into range clipping (no HDR support in min,max perc. components). This is the initial sum buffer.

Then we start the expansion:

Expand sum by 1 pixel, add to sum (gradient span now: 2 px)
Expand sum by 2 pixels, add to sum (gradient span now: 4 px)
Expand sum by 4 ..
Expand sum by 8 ..
Expand sum by 16 ..
Expand sum by 32 ..
Expand sum by 64 pixels, add to sum (gradient span now: 128 px)

The numbers above are the theoretically correct ones, but in FF you don't get to deal with pixel spans, so thats why the current settings relate to the image size. I can figure out the percentage value equivalent to one pixel, but this is in green sample connection and I can't use that to set the min. radius. Perhaps the scale transformation can solve this.

In addition to the expansion accumulation I do some clipping which drastically reduces memory usage and processing time (without clipping its like 20-30 secs for 600x600, with clipping its relative to the actual shape size, often only a few secs of processing).

For simplicity I only show either inner or outer distance transform. The really cool thing is that you can do both with little extra overhead (hint invert the original shape and plug it into another channel, clipping needs tweaking though).

  Details E-Mail
Sphinx.
Filter Optimizer

Posts: 1750
Filters: 39
Ok, I partly figured out how to make radius of the min filtering relative to the image size. This unclipped test version exploits the special case motion blur offset that lets you find the percentage value equivalent to 1 pixel.

The radius parameter in the Minimum component is acting pretty strange though - its not as consistent as in the blur components. I think some sort of truncation is going on. Perhaps Vlad or someone from the dev. team can shed some light on this?

Next thing is to figure out the correct normalization... should be possible.

The Span Step Size parameter controls how wide each gradual step is (½ to 1½ or 2 px.. can't remember), it affects both quality and final transform width.

Distance SCALE.ffxml
  Details E-Mail
tigerAspect
Posts: 222
Filters: 9
Oooh, nifty.
2 things: first is that I think you still have LDR clipping issues, I'm getting confused as to what I've changed and why, but I had to drop the initial multiply to 0.5. Second, as far as I can tell, you ARE dealing with percentages, you've figured out a really neat way of making 1% = 1px, but your power of 2 scale stops at 96%, so the large areas in your example shape (which is really cool btw I'll be stealing that idea smile;)) have flat top areas, I've attempted to fix this with a hacked solution involving 1 final Min step with a wierd If step where the flat area (those equal to 0.64 RGB values) is replaced with a down-scaled sample from the final min step, but that seems to hang FF o.O.

It's also slow as hell. smile:D
  Details E-Mail
tigerAspect
Posts: 222
Filters: 9
Actually, thinking about it, the flat areas would just be areas where the shape exceeds 128px in width, so disregard my percentage comments smile;)
  Details E-Mail
Sphinx.
Filter Optimizer

Posts: 1750
Filters: 39
Yeah, the flat areas are there because the expansion chain is not long enough. Its possible to add more first in the chain (i.e. radius 0.5 and 0.25), but the scaling needs adjustment relative to that.

While this scaling trick seems to work, its not working well with the threshold clipping. When I add that, the filter takes forever (10-15 mins :-S). I think the scaling has some nasty internal consequences (extremely large temporary bitmaps or something). The scale hack is not that attractive after all. I wish we had more options for controlling / working with grey constant inputs - remap options are too limited for this stuff.
  Details E-Mail

Join Our Community!

Filter Forge has a thriving, vibrant, knowledgeable user community. Feel free to join us and have fun!

33,712 Registered Users
+19 new in 30 days!

153,534 Posts
+31 new in 30 days!

15,348 Topics
+72 new in year!

Create an Account

Online Users Last minute:

21 unregistered users.