It is currently Tue Jul 02, 2024 3:25 am


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: Help with plug-in-displace and plug-in-colors-channel-mixer
PostPosted: Mon Nov 07, 2011 1:15 pm  (#1) 
Offline
GimpChat Member

Joined: Nov 07, 2011
Posts: 6
I'm trying to write a plugin that will create red-cyan anaglyphs from an image and a depth map (as well as learn how to write Gimp scripts).
The things that are broken are the non-interactive use of the displace plugin and the channel mixer.
I get a 'vector-ref out of bounds' error for the displacement plugin.
For the channel mixer instead of layer's channel being changed somehow it acts as if the layer is all white and changes the channels for that. (Although at one point I think it was working properly..but I can't get it back to behaving.)
(define (script-fu-anaglyph theImage drawable)
  (let* (
;       (cyanLyr (car (gimp-layer-copy drawable TRUE)))                                                                                                         
;       (redLyr (car (gimp-layer-copy drawable TRUE)))                                                                                                         
        (theLayersList (cadr (gimp-image-get-layers theImage)))
        (theImageMapLayer (aref theLayersList 0))
        (theBackgroundLayer (aref theLayersList 1))
        (redLyr (car (gimp-layer-copy theBackgroundLayer TRUE)))
        (cyanLyr (car (gimp-layer-copy theBackgroundLayer TRUE)))
        )

;theLayersList gave unbound variable?? when it was just let instead of let*                                                                                     

    (gimp-image-add-layer theImage cyanLyr -1)
    (gimp-drawable-set-name cyanLyr "Cyan")
    (plug-in-colors-channel-mixer RUN-NONINTERACTIVE theImage cyanLyr FALSE 0.0 0.0 0.0 100.0 100.0 100.0 100.0 100.0 100.0 )


    (gimp-image-add-layer theImage redLyr -1)
    (gimp-drawable-set-name redLyr "Red")
    ;(plug-in-colors-channel-mixer RUN-NONINTERACTIVE theImage redLyr FALSE 100.00 100.0 100.0 00.0 00.0 00.0 00.0 00.0 00.0 )                                 
    (gimp-layer-set-mode redLyr SCREEN-MODE)

                                        ;(gimp-curves-explicit cyanLyr HISTOGRAM-RED                                                                           
                                        ;perform displacement                                                                                                   
;    (plug-in-displace RUN-NONINTERACTIVE theImage cyanLyr 10 0 0.0 0 theImageMapLayer theImageMapLayer 1)                                                     
;    (plug-in-displace RUN-INTERACTIVE theImage cyanLyr 10 0 0.0 0 theImageMapLayer theImageMapLayer 1)                                                         
                                        ;0 WRAP 1 SMEAR 2 BLACK                                                                                                 
    (plug-in-displace RUN-NONINTERACTIVE theImage redLyr -10.0 0.0 1 1 theImageMapLayer theImageMapLayer 2)  ;if the do-x and do-y variables (currently 1's to 0's) then I don't get the vector-ref out of bounds error                                                                                                       
;   (plug-in-displace RUN-INTERACTIVE theImage redLyr -10 0 TRUE TRUE 0 theImageMapLayer theImageMapLayer 2)                                                   
    (gimp-displays-flush)
    )
  )
(script-fu-register "script-fu-anaglyph"
                    _"<Image>/Script-Fu/Anaglyph"
                    "Processes an image and depth-map into a red-cyan anaglyph"
                    "InkyDinky"
                    "InkyDinky"
                    "2011 11 7"
                    "*"
                    SF-IMAGE        "Image"     0
                    SF-DRAWABLE     "Drawable"  0
                    )
                                        ; the Red layer is the top layer, set to screen mode                                                                   
                                        ; even though we opened two parens we only close one here, close the other at the end of the script

I'm new to scripting so please be gentle. I've looked at the tutorials and they aren't much help for my problems.
Any help is greatly appreciated.
Running GIMP 2.6.11
Thanks!


Attachments:
File comment: attached script
Test.scm [2.07 KiB]
Downloaded 134 times


Last edited by InkyDinky on Mon Nov 07, 2011 2:44 pm, edited 1 time in total.
Share on Facebook Share on Twitter Share on Orkut Share on Digg Share on MySpace Share on Delicious Share on Technorati
Top
 Post subject: Re: Help with plug-in-displace and plug-in-colors-channel-mixer
PostPosted: Mon Nov 07, 2011 2:24 pm  (#2) 
Offline
GimpChat Member
User avatar

Joined: May 16, 2010
Posts: 14709
Location: USA
Shouldn't x and y displacement be 10.00 ?
Channel mixer i am not sure of.

_________________
Image
Edmund Burke nailed it when he said, "The only thing necessary for the triumph of evil is for good men to do nothing."


Top
 Post subject: Re: Help with plug-in-displace and plug-in-colors-channel-mixer
PostPosted: Mon Nov 07, 2011 2:33 pm  (#3) 
Offline
Script Coder
User avatar

Joined: Apr 23, 2010
Posts: 1553
Location: not from Guildford after all
Try removing the backslash and either joining the two lines or inserting a semi-colon to comment the second line.

_________________
Any sufficiently primitive technology is indistinguishable from a rock.


Top
 Post subject: Re: Help with plug-in-displace and plug-in-colors-channel-mixer
PostPosted: Mon Nov 07, 2011 2:43 pm  (#4) 
Offline
GimpChat Member

Joined: Nov 07, 2011
Posts: 6
Nope we only want to displace X.
Think of your eyes. They are a stereo pair. They have a X offset but not a Y offset.


Top
 Post subject: Re: Help with plug-in-displace and plug-in-colors-channel-mixer
PostPosted: Mon Nov 07, 2011 3:15 pm  (#5) 
Offline
GimpChat Member
User avatar

Joined: May 16, 2010
Posts: 14709
Location: USA
saulgoode wrote:
Try removing the backslash and either joining the two lines or inserting a semi-colon to comment the second line.


Saul would you mind explaining what you mean by "backslash" ?

Thanks.

_________________
Image
Edmund Burke nailed it when he said, "The only thing necessary for the triumph of evil is for good men to do nothing."


Top
 Post subject: Re: Help with plug-in-displace and plug-in-colors-channel-mixer
PostPosted: Mon Nov 07, 2011 3:32 pm  (#6) 
Offline
GimpChat Member

Joined: Nov 07, 2011
Posts: 6
I edited the code that is displayed in the code block that I think he was referring to.
When I pasted from my editor it inserted the / for the line break.


Top
 Post subject: Re: Help with plug-in-displace and plug-in-colors-channel-mixer
PostPosted: Mon Nov 07, 2011 3:36 pm  (#7) 
Offline
GimpChat Member
User avatar

Joined: May 16, 2010
Posts: 14709
Location: USA
Ahh okay, thanks. :)
Welcome to Gimp Chat by the way.

_________________
Image
Edmund Burke nailed it when he said, "The only thing necessary for the triumph of evil is for good men to do nothing."


Top
 Post subject: Re: Help with plug-in-displace and plug-in-colors-channel-mixer
PostPosted: Mon Nov 07, 2011 11:01 pm  (#8) 
Offline
GimpChat Member

Joined: Nov 07, 2011
Posts: 6
Well I have a working script.
I didn't solve the channel-mixer problem. The documentation isn't clear as to what the "gain" does for the color.
I had to work around this problem.
And as far as the displace plugin I had to set the do-x and do-y options to 1 otherwise it wouldn't work.
Here is my working script and a sample image to play with.
The images work best with a depth map from 0-127 and not 0-255
And BTW the cartestion/polar option doesn't do anything in the pop up menu.
Enjoy and happy anaglyphing!


Attachments:
Zelda_by_Fennewalde.xcf [3.35 MiB]
Downloaded 173 times
Anaglyph3.scm [4 KiB]
Downloaded 160 times
Top
 Post subject: Re: Help with plug-in-displace and plug-in-colors-channel-mixer
PostPosted: Tue Nov 08, 2011 1:01 am  (#9) 
Offline
Script Coder
User avatar

Joined: Apr 23, 2010
Posts: 1553
Location: not from Guildford after all
InkyDinky wrote:
Well I have a working script.
I didn't solve the channel-mixer problem. The documentation isn't clear as to what the "gain" does for the color.

The gain values of the PDB function are multiplication factors, not the percentage values expected by the dialog interface.

For example, to convert a layer to grayscale luminance using CIE Rec. 709 weighting (0.2126*R + 0.7152*G + 0.0722*B), you would use:
(plug-in-colors-channel-mixer RUN-NONINTERACTIVE image layer FALSE
                              0.2126 0.7152 0.0722
                              0.2126 0.7152 0.0722
                              0.2126 0.7152 0.0722 )


or to extract the green channel only:
(plug-in-colors-channel-mixer RUN-NONINTERACTIVE image layer FALSE
                              0 0 0
                              0 1 0
                              0 0 0 )

_________________
Any sufficiently primitive technology is indistinguishable from a rock.


Top
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts Attachment(s) Don't work procedures plug-in-bump-map, plug-in-displace

2

No new posts Attachment(s) I need help about ofn-plug-ins

19

No new posts Attachment(s) Saturation H M L plug-in

17

No new posts Attachment(s) Can someone repair this plug-in?

11

No new posts Attachment(s) Surround Me Plug-in

19



* Login  



Powered by phpBB3 © phpBB Group