Replace rgb1 with rbg2

Wilhelm Sanke sanke at
Wed May 12 10:07:21 CDT 2010

On Tue, 11 May 2010, JosepM<jmyepes at>  wrote:

> Hi List,
> How can I change one color rgb by other color rgb into a image?
> I found some scripts in the list that show some ideas to accomplish it. But
> nothing work for me.
> I binaryencode("C",red) to replace with other binaryencoded value, but no
> result
> I replaced using numtochar, but no result
> It's posible do the operation inside a rect of some object?
> Any idea?
> Salut,
> Josep


your question had also been asked on this list on March 15 by Tiemo Hollmann.

For my convenience I quote here my answer to Tiemo's question along with examples of images with "replaced colors" and links to scripting such replacing:

On  March 15, 2010, Tiemo Hollmann TB toolbook at wrote:

>  I am not that familiar with the image manipulating capabilities of rev. I
>  have a batch of images with a person in front of a blue background.
>  What I would like to do is to change the blue background against a white
>  background, so that a printed image has a better contrast. Up to now I
>  thought that this is a photoshop job, but I am always again surprised what
>  people do with rev (blending, masking, etc.). Or any externals for Mac and
>  Win? I don't know if at all it would be possible, to find and select
>  automatically the "background" (e.g. select always the topleft corner) and
>  select all of the blue, like photoshops wizard selecting tool with some
>  tolerance of 10 or 20%, because the RGB isn't that plain over the whole
>  background.


stephen barncard stephenREVOLUTION2 at answered:

>  you mean you want a "magic wand" or "replace color" tool? I don't think rev
>  can do that natively. Adobe may even have a patent on it.

I think "to replace a color in an image" is one of the simpler tasks feasable with Rev (see farther below for the recipes).

There are some on this list that have explored possibilities of image editing with Rev - and from which I have learned much when I started myself to experiment with such things. Some of the results and related image-manipulating tools can be inspected on my website


The two "Imagedata Toolkits" from 2006 and 2007 contain more than hundred filters and other tools to manipulate images. A number of newer stacks are still in the process of being prepared for public release.

The basic problem with using Rev for image processing is that with big-sized images the processing speed can be very, very slow. Another problem are a number of bugs in Rev that led to rather frequent crashes when I was working on a set of other tools ("Photo Patchworks", "Gradientology", "Kaleidoscope Tool"), which has substantially delayed their release - along with the fact that Rev is no longer in the center of my interests as it has been before.

I have addressed the speed and crash problems on various occasions and also in my last post to this list of March 9: "Language comparisons: "Lua" - simpler and faster than RevTalk?" (which you can also get from here:

and in which I announced two other stacks "Exploring Hues" and "Lua Filters". Both stacks contain "replace" tools, one that I ported from Lua and others that I had developed earlier on my own.

Concerning Tiemo's question:

I replaced (a range of) colors colors in two images in two different ways:

1. Replacing a color range with a "plain" replace color

2. Replacing a color range while preserving "structures" in the color area being replaced, for examples the clouds on the blue sky that now look red like the replaced color of the sky, but remain discernible inside the new red background.

Two examples for each approach:



You find the necessary scripts here:


The procedures to replace the colors in this case are like here (many other approaches are of course possible).

- select a color-to-be-replaced by clicking on the image and getting the "mousecolor" using a script in the image

- define a "range" for that color via an ask dialog

- get the replace color from somewhere; in my case I used a color field whose background colors I set with RGB sliders - as in the "Color Chooser" stack.

- finally press the replace button (and repeat that process if necessary to refine color selection and range).

I also use a movable graphic on top of the image to restrict such "replace color" (or any other) effects to a specific area of the image.

Kind regards,

Wilhelm Sanke

More information about the use-livecode mailing list