On Monday 29 November 2004 22:25, Joseph Heled wrote:
> (I think this has been discussed on the list before, but not sure
> where/when.)
>
> What is the best way to achieve the following functionality -
>
>    Given two layers L1 and L2, I want L2 limited by it's distance
> from L1
>
>        Result  <-  L1 - MIN( MAX(L1 - L2), -20), 20)
>
> (This expression uses L1/L2 as placeholder for each pixel in all
> RGB channels)
>
> Options:
>
> A. Write a plugin
>
> B. Write it as a script-fu (not sure if script-fu can iterate on
> pixels, and what is the speed implication). And I hate scheme.
>
> C. Write it in python fu if I can compile it, but even though it is
> probably not as universally available as scrip-fu. Can I iterate
> over an image in python-fu?

This one, or the C plugin. In python fu you can iterate over pixels, 
and still have all the ase of use of the PDB API, and from the python 
language itself. But it's slow to interate over pixels. If you want 
more speed, you either have to go to C, or use a python extension 
called "pyrex"which allows one to declare C langauge objects within 
python syntax, therefore gaining speed.

But it so easy in python that I could write you the plug-in in little  
time -  I just an not sure of what you want to achieve - Your 
"result" would be stored in the Layer 2 pixels? or on a  3 layer (/me 
thinks would be better) 
> D. I know I can do it with 5 layers and overlay modes. write this
> as a script-fu. Not elegant and requires loads of memory for large
> images.
>
>   Layer   Mode
>
>   L1     Grain Merge
> 148     Darken Only
> 108     Lighten Only
>   L1     Grain Extract
>   L2     Normal
>
> (148/108 stand for a layer filled with gray pixels
> (148,148,148)/(108,108,108)

Brrr... But you could also use a pythonfu script to control teh 
creation and placement of these five layers.
>
> E. Write a generic framework which allows any kind of expression(s)
> between layer(s)  (Only kidding ...)

No kidding - I have this code written down. 
But I did this for old gimp 1.3.14, and never broguthit upt o date, or 
wrote an itnerface for writing or compiling the generic expresion.

I call it ¨ the custom layer mode", and I actually have plans to bring 
it back from the not-quite-dead.

I will do you a template for the python plugin for now. To compile it 
in posix systems, just add "--enable-python" to your confgure 
directives. Peope on gimp-users have info on building it for windows.


Regards, 

>
> F. Anything better?

Can't think of anything that surpasses "E". C will do for you, if you 
have patience each time you change yor source layers.

>
>
> -Joseph
>
_______________________________________________
Gimp-developer mailing list
[EMAIL PROTECTED]
http://lists.xcf.berkeley.edu/mailman/listinfo/gimp-developer

Reply via email to