Jump to content


Photo

Get Values Out Of The Custom Tool

Fusion Expression

  • Please log in to reply
8 replies to this topic

#1 hst

hst

    Piglet

  • Adv Members
  • 9 posts

Posted 04 April 2012 - 05:04 AM

Imagine this: In the normal custom tool you use the line getr1b(0,0) as Red Expression. So far, so good, The output red channel will be the red value of the bottom left pixel.
But how do I get this value for further use, such as a rotation value of some transform? The Expression lasso just returns "CustomTool1.RedExpression".
Of course I could use the handy Probe modifier here, but there must be another way ... something like eval() ...

#2 bfloch

bfloch

    Flying Pig

  • Adv Members
  • PipPipPipPipPip
  • 960 posts

Posted 04 April 2012 - 07:58 AM

The custom tool expression is evaluated (internally) for every pixel during processing of the custom tool. What would you expect to be returned? There is neither a way to get the evaluated expression nor a way to have an datatype passed that supports all processed pixels - other than the resulting image - which is ultimately what you get with a custom tool.

Probe is what you need here. It does essentially the very same that getr1b does only that it results in one number which can be handled by control inputs.

#3 hst

hst

    Piglet

  • Adv Members
  • 9 posts

Posted 04 April 2012 - 10:50 AM

My goal is to get the result of an expression - in this case: the value that is copied to the whole red channel, something between 0.0 and 1.0.
But this example was only to represent my goal; to get the result of an expression ...

Probe's nice, but after 100 probes parallel things start to slow down... and I aim to read 3600 luminance values at once (with some py script)

Anyway, thanks for the information. So I'll stop searching & rather try some workaround.

#4 SecondMan

SecondMan

    Flying Pig

  • Adv Members
  • PipPipPipPipPip
  • 1,797 posts

Posted 04 April 2012 - 11:48 AM

Maybe if you would outline what it is you are trying to do? Whatever it is, it sounds like you are taking a brute force approach to something and in many cases that is not necessarily the most efficient way to get to a result...

#5 Tilt

Tilt

    Flying Pig

  • Validating
  • PipPipPipPipPip
  • 2,137 posts

Posted 04 April 2012 - 12:00 PM

If you want to access the pixels of an image and do something with them, I'd suggest you write a Fuse. It can only be written in Lua, but you can use it to sample all the pixels you need. The values could even be written to a text file if you need them outside of Fusion.

#6 ChadCapeland

ChadCapeland

    Flying Pig

  • Adv Members
  • PipPipPipPipPip
  • 1,975 posts

Posted 04 April 2012 - 12:38 PM

Single pixels read out to a number or point would be really fast in a Fuse. Not sure if it would beat out a Probe though. But yeah, it sounds like you might be asking for something specific in the wrong way.

#7 bfloch

bfloch

    Flying Pig

  • Adv Members
  • PipPipPipPipPip
  • 960 posts

Posted 04 April 2012 - 01:15 PM

You could also simply save the image and read it with one of the available python image libraries. No need to write a fuse / custom format. All this can be scripted.

#8 hst

hst

    Piglet

  • Adv Members
  • 9 posts

Posted 05 April 2012 - 03:41 AM

I came across this "problem" a few times. Usually there is some workaround (so it was here). But I started this post in order to get a deeper understanding of Fusion's architecture. It's always better to know if something is not possible than to search 'till midnight.
The fuse idea sounds interesting, I'll give that a try.

Anyway, thanks for your help guys!

#9 hst

hst

    Piglet

  • Adv Members
  • 9 posts

Posted 05 April 2012 - 03:50 AM

Oh, here's a glimpse of what this topic was about.

Just run the py script out of fusion (/scripts/comp), play with the values and draw a mask in the automatic created ply node.

I appologize for the german GUI ... didn't thought I'll ever share that one. At least the comments are english :-)

cheers


Attached File  planes_02.zip   2.14KB   11 downloads





Also tagged with one or more of these keywords: Fusion, Expression

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users