It is currently Thu Apr 25, 2024 5:36 pm


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: scheme question on indexed colors
PostPosted: Tue May 26, 2015 11:07 pm  (#1) 
Offline
Script Coder
User avatar

Joined: May 07, 2014
Posts: 3975
Location: Canada
I want to convert an image to indexed colors using something like 3 to 10 colors.
I got that step.

Now i am onto getting these indexed colors so that i can select by color tool each one of the colors one by one to perform a function (hatching script i created).
which functions should i be looking at?

At some point before calling my function (hatching script) I have to convert back into RGB to use other color values, i'll have to manually calculate the RGB values.

Any help is appreciated.
Thanks in advance.

I tried
(set! palette-name (gimp-context-get-palette))   
(set! num-of-colors (car (gimp-palette-get-colors palette-name)))      
(set! color-array (caadr (gimp-palette-get-colors palette-name)))

but it's giving me error on gimp-palette-get-colors about "Error: ( : 1) Invalid type for argument 1 to gimp-palette-get-colors"
also what's weird if i run the script again it's complaining that the image is already in indexed mode
but the image doesn't seem to be converted ..but if i switch to indexed mode manually nothing happens and if i manually convert back to RGB then it shows it indexed colors (5 colors in this example) its' as if my errors on getting the palette has left gimp confused between these modes.

_________________
TinT


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: scheme question on indexed colors
PostPosted: Tue May 26, 2015 11:59 pm  (#2) 
Offline
Script Coder
User avatar

Joined: Apr 23, 2010
Posts: 1553
Location: not from Guildford after all
Quote:
(set! palette-name (gimp-context-get-palette))


All values returned from PDB functions are in the form of a list. In this case, the palette name is the first item in that returned list.


(let* ((color-map (vector->list (cadr (gimp-image-get-colormap image)))))
  (let loop ((colors color-map)
    (unless (null? colors)
      (let ((red (car colors))
            (green (cadr colors))
            (blue (caddr colors)))
        (gimp-image-select-color image CHANNEL-OP-REPLACE layer (list red green blue))
        ; << DO HATCH STUFF HERE >>
        )
      (loop (cdddr colors)))))

_________________
Any sufficiently primitive technology is indistinguishable from a rock.


Top
 Post subject: Re: scheme question on indexed colors
PostPosted: Wed May 27, 2015 12:01 am  (#3) 
Offline
Script Coder
User avatar

Joined: May 07, 2014
Posts: 3975
Location: Canada
thanks a lot...i'll try it.

I couldn't get your code to work i had to use a while loop but it works thanks for pointing me to colormap.

_________________
TinT


Top
 Post subject: Re: scheme question on indexed colors
PostPosted: Wed May 27, 2015 2:41 am  (#4) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4739
I see where you are going and if I were you I would use the technique I used in my luminosity-tiler script:
- Make a stack of layers, one per hatching, stacked in order of apparent luminosity (say, dark at bottom)
- Each layer (except bottom) get a layer mask which is a grayscale version of the original image
- Each layer mask is thresholded with progressive threshold, the topmost having a mask that makes only the very light parts opaque.

You get a much finer control on the hatching<->luminosity that way (a user can even replace a mask after the script has run to fix pathological cases...)

_________________
Image


Top
 Post subject: Re: scheme question on indexed colors
PostPosted: Wed May 27, 2015 2:46 am  (#5) 
Offline
Script Coder
User avatar

Joined: May 07, 2014
Posts: 3975
Location: Canada
thanks.
I might look into it..right now it does create separate layers for each hatch, but instead of creating a mask i just did the obvious way to me which was to cut away the unneeded parts.

_________________
TinT


Top
 Post subject: Re: scheme question on indexed colors
PostPosted: Wed May 27, 2015 4:47 am  (#6) 
Offline
Script Coder
User avatar

Joined: Apr 23, 2010
Posts: 1553
Location: not from Guildford after all
trandoductin wrote:
I couldn't get your code to work i had to use a while loop but it works thanks for pointing me to colormap.

There should've been an additional right parenthesis ")" at the end of the following line.

(let loop ((colors color-map)

_________________
Any sufficiently primitive technology is indistinguishable from a rock.


Top
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts Attachment(s) exporting 256-color indexed png & gif missing transparency

9

No new posts Attachment(s) Did something change in scheme in 2-10-20[Solved]

5

No new posts Attachment(s) "Indexed" in Image->Mode is disabled.

8

No new posts Attachment(s) Falling snow animated Scheme Script for Gimp

121

No new posts Attachment(s) Colors and Patchwork

2


cron

* Login  



Powered by phpBB3 © phpBB Group