I want to write some plug-ins in Prolog.  I don't want to deal with any C 
pointers, while-loops or if-thens.  Although the code below doesn't make use of 
it, I want to make use of Prolog backtracking in order to find a correct 
solution through trial-and-error, such as filling a region with a texture that 
melds into all edges with no abrupt color differences.  I want to be able to 
write code such as this, in Prolog, for the blur function for example

blur(In, Out) :- blur(In, Out, In).   %the function needs to access input 
pixels more than %once (not just when they are at the head of the input list), 
so pass on another copy of the %input as the 3rd argument
blur([], [], _). %when there is no more input, there is no more output, so stop
blur( [X-Y-A-R-G-B | Input_Tail], [OX-OY-OA-OR-OG-OB | Output_Tail], Input) :-
    %find all the neighbors of current pixel, average them, and unify result 
with head of 
    %the output list
    findall( X2-Y2-A2-R2-G2-B2, (
                                                 neighbor(X-Y, X2-Y2),
                                                 member(X2-Y2-A2-R2-G2-B2, 
Input),
             Neighbors),
   average_pixels(Neighbors, OX-OY-OA-OR-OG-OB),   
   blur(Input_Tail, Output_Tail, Input).   %recursion

I want to be able to deal with the input and output in the form of a Prolog 
list, one list for each layer.  And for multiple layers, a list of lists.  The 
code above is written for one layer.

Each pixel could come in the form of X-Y-A-R-G-B (integers separated by 
hyphens) where X and Y are the location coordinates, A is the alpha channel, 
and R-G-B are their respective RGB values.

I understand that processing the data in Prolog would come with performance 
drawbacks, but I want to make use of backtracking, and I don't want to be 
dealing with for-loops and array pointers when I'm defining the output.  If it 
needs to be optimized somebody could rewrite it into C.  

Is there anyone who has written plug-ins before in the C language that would be 
able to help me make a Gimp <-> Prolog interface so that Prolog programs can be 
run from a Gimp plug-in.  I want to have a new plug-in under Filters->Prolog 
that will open up a list of *.pl files in the plug-ins directory (*.pl meaning 
Prolog file extension).  I can then choose a *.pl file and the plug-in will 
then communicate with Prolog.  So in other words, instead of compiling a 
plug-in for Gimp every time, this single plug-in will be able to run all Prolog 
programs in their *.pl form as soon as they are written.  

Preferring to work in Prolog I need some help from a C programmer to write this 
plug-in.  I'd appreciate any help from someone who has written a plug-in before.

Ryan
_______________________________________________
Gimp-developer mailing list
Gimp-developer@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer

Reply via email to