image in white rectangle

Ben Rubinstein benr_mc at cogapp.com
Wed Dec 15 04:50:32 EST 2004


Andrew wrote:
> Say I'm importing an image of a person standing in full figure against
> a white background.  When this image is in front of another larger
> image, you can see the white background behind the person.  I just want
> to make the white background behind the person invisible so it just
> looks like the person is standing in front of the other picture.

I can testify that doing this to a real world image is not trivial (and
doing it fast, even more so).

I used Rev a couple of years ago for an application where members of the
public took a photo of themselves in front of a blue screen, and then used a
touchscreen to manipulate the photo in various ways (adding different
backgrounds, props etc).  The project was ultimately a success (and I still
get a very entertaining check feed of images, peaking at around 50 a day)
but it was a nightmare, and we wrote off a bundle on it.

I confidently and naively assumed that I would take an RGB point that was
the 'pure' (or at least average) bluescreen colour, construct a sphere
around this, and make transparent any pixel with a colour in this space.
Then I decide I needed an inner and outer sphere, with a penumbra of
transparency falling off from one to the other.  Then I tried something
else, ... and so it went on.

I was partly handicapped by the architects (who decided that they didn't
like the standard bluescreen colour, and went for a dark green instead (!)
and also ignored everything we told them about lighting for blue screen, and
saved money by using the worst possible option.  And the speed issue was
greatly magnified because although I coded the backend app which took the
photo and added transparency in Revolution, I lost the battle to have the
frontend app in Revolution as well; it was coded in Director, which proved
to be a massive cycle hog.  My app which took 10 seconds (which seemed long
but acceptable) to process the image when running in the foreground, took
four minutes when Director - doing nothing - was active.  So that put the
pressure on.

But the whole experience greatly increased my respect for Photoshop et al!
There's no such thing as a flat colour in a real-world photo.  And depending
on the image source, all sorts of strange colour pixels can turn up in an
area which broadly looks like one colour.

Depending on your application, I'd say: either allow for a _lot_ of
development time; explore the ways in which you can alter the environment
(making the source image more helpful is a lot easier than trying to solve
the problems afterwards); consider whether you might do better to build on
someone else's work, seeing if you could AppleScript Photoshop or a similar
app to do this work for you.  Possibly all of the above!
 
  Ben Rubinstein               |  Email: benr_mc at cogapp.com
  Cognitive Applications Ltd   |  Phone: +44 (0)1273-821600
  http://www.cogapp.com        |  Fax  : +44 (0)1273-728866



More information about the use-livecode mailing list