next up previous contents index
Next: A good example of Up: Program examples Previous: Let's get practical!   Contents   Index

And if you want a negative??

To change an image to a negative, you can use the same process, except that instead of averaging the numbers r g b, you replace them by the number you get when you subtract them from 255. Eg: If a pixel has the colour [2 100 200], you replace it with the colour [253 155 55]

Only the pixel procedure needs to be changed in the following program:

to greyscale :c
if :y=-100 [stop]
if :c=100 [make "c 0 make "y  :y-1] 
setpc pixel fc list :c :y
dot list :c :y
greyscale :c+1
end

to transform
# You must change the path to the image transfo.png
# Eg: setdir "c:\\my_images loadimage "transfo.png] 
ht cs setdir "/home/loic loadimage "transfo.png make "y 0 greyscale 0
end

to pixel :list
make "r first :list
make "list bf :list
make "g first :list
make "liste bf :list
make "b first :list
output se list 255-:r 255-:g 255-:b  
end
Figure: XLOGO pretending to be the GIMP ...(pretentious? :-))
\includegraphics{pics/transfo2.eps}



Loïc 2008-06-08