tags:

views:

28

answers:

2

Let's say I have a picture, I want to create some variations by changing a color. How to do this ?

I don't want to apply color filter to a picture, I want to change pixels color pixel by pixel by testing a color pixel if it is let's say red, i want to turn it to blue.

A: 

Use some of the image processing capabilities as documented here: http://www.rebol.com/docs/view-guide.html

Demo program showing some of them in action here: http://www.rebol.com/view/demos/gel.r

Sunanda
Hi Sunanda I have looked at gel code but I can't see how it shows anything related to what I would like to do ? It is about special effect, I don't want to do any, just replace a color.
Rebol Tutorial
I don't want to apply color filter to a picture, I want to change pixels color pixel by pixel by testing a color pixel if it is let's say red, i want to turn it to blue.
Rebol Tutorial
+1  A: 

In Rebol images are also series, so you can use most of the series functions to change/find rgb colors etc.

i: load %test.png
type? i
image!
first i
255.255.255.0 (the last value is alpha)
change i 255.0.0.0 ;change the first rgba value to red
view layout [image i] ;you can see the upper-left pixel is now red

you can dump all rgba values in an image:

forall i [print first i]

you can also change a continues part:

change/dup head i blue 100 ;change first 100 pixels to blue

you can also work on i/rgb and i/alpha, these are binary values (bytes) and you can use copy to get a part of an image:

j: copy/part at i 100x100 50x50 ;copy from 100x100 to 150x150 to a new image.
endo64
and here is the example which replaces all the white pixels to blue. forall i [if white = first i [change i blue]]
endo64
That's exactly what I wanted and more ... thank you very much :)
Rebol Tutorial