Replace colors (was: can rev supply image editing features?)

Wilhelm Sanke sanke at hrz.uni-kassel.de
Tue Mar 16 15:10:57 EDT 2010


On  March 15, 2010, Tiemo Hollmann TB toolbook at kestner.de 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.

and

stephen barncard stephenREVOLUTION2 at barncard.com 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

<http://www.sanke.org/MetaMedia>.

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:
<http://www.sanke.org/MetaMedia/LanguageComparisonsLua.rtf>)

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:

<http://www.sanke.org/MetaMedia/Town-original.jpg>
<http://www.sanke.org/MetaMedia/Town-RedBG-plain.jpg>

and
<http://www.sanke.org/MetaMedia/Landscape-original.jpg>
<http://www.sanke.org/MetaMedia/Landscape-RedBG.jpg>

You find the necessary scripts here:

<http://www.sanke.org/MetaMedia/ReplaceScripts.rtf>

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