[plt-dev] 2htdp/image: Where oh where have my pinholes gone?

From: Carl Eastlund (cce at ccs.neu.edu)
Date: Tue Jan 12 16:40:33 EST 2010

Why not just have pinholes, and not use them unless you need them?  Or
explore other options?  I mean... recursion is complex, math is
complex, should we take them out?  Why did we go straight from "it's
complex" to "let's remove it"?

Carl Eastlund

On Tue, Jan 12, 2010 at 4:36 PM, Robby Findler
<robby at eecs.northwestern.edu> wrote:
> This is why pinholes are good, but it was decided that they are too
> complex so they're now gone.
> I don't have any good solutions, but beyond the ones you mentioned
> below, you could also crop out the parts that hang out, making sure
> you don't lose waldo (altho you will lose bits of his accessories).
> Or, of course, you can put waldo into a structure and track pinholes
> yourself (the math isn't that bad if you have a helper function that
> wraps underlay/xy).
> Robby
> On Tue, Jan 12, 2010 at 3:25 PM, Carl Eastlund <cce at ccs.neu.edu> wrote:
>> I understand that relative coordinate systems are confusing, and where
>> it is possible to get by without them, it simplifies matters to do so.
>>  However, when I need them, nothing else will do.
>> Here is the problem.  I have a picture of a guy.  Let's call him
>> Waldo.  I want to show Waldo standing in his eternally fixed pose,
>> overlayed with a variety of clothing and accessories.  Maybe I can put
>> a hat on his head, a skateboard under his feet, or a leash in his hand
>> leading to a dog standing next to him.  Whatever.  I have a picture of
>> Waldo, I know where his head, hands, and feet are relative to his
>> center of mass (say, his belt buckle), and I should be able to put one
>> or more pictures at these points to make a composite image.  Right?
>> I tried coding this up using htdp/image, no problem.  Waldo is a blue
>> rectangle, his hat a green triangle, his mittens red circles, and his
>> boots black ellipses.  Image construction was a simple matter of
>> overlay/xy.  The result is attached in "htdp-overlay-xy.ss".  The
>> final picture shows the blocky, blue Waldo wearing a hat and
>> symmetrically-placed mittens and boots.
>> Then I tried coding this up in 2htdp/image.  Some problems.  Just
>> "underlay" (overlay is no longer the right direction) doesn't do what
>> I want -- it's not relative at all, the hat and mittens and boots
>> would all do the same thing.  The "underlay/align" function looks
>> promising, but it turns out that putting the hat at the "top" means
>> the top of the hat aligns with the top of Waldo's head.  So the hat is
>> more like a mask.  The mittens and boots, likewise, are applied to
>> Waldo's (visible) torso, rather than his (imaginary) limbs.
>> I also tried "underlay/xy", which should let me pick any offset I
>> want.  Unfortunately, that offset is always relative to the upper left
>> corner of the bounding box of the resulting image.  And as soon as I
>> put on Waldo's hat, that bounding box shifts up.  So his left mitten
>> applies somewhere higher than Waldo's hand, more like his shoulder.
>> That, in turn, shifts the bounding box to the left, so the right
>> mitten is over his torso -- probably on top of his right ear.  The
>> left boot, which brushes against Waldo's hip, pushes the bounding box
>> even further to the left, so Waldo's right boot winds up acting as a
>> codpiece.
>> The problem is that as soon as I overlay an accessory onto Waldo, I
>> have lost track of his center of mass; I don't know where his belt
>> buckle is, and as a result, where his head, hands, and feet are.  Once
>> I add an accessory, I know where the center and edges of the new image
>> are, but I have lost track of my starting point.  Further accessories
>> become harder and harder to add.
>> There are a couple of possible solutions here, but I don't find them
>> compelling, especially in a classroom scenario as an explanation of
>> how to build up values recursively.
>> One is to put Waldo on a big white background, so that his bounding
>> box does not change as I add accessories.  This, however, requires
>> that I predict the largest possible accessory before I draw Waldo.  It
>> also reintroduces the notion of a Scene, because now I do not have an
>> individual image composed of parts, I have one big canvas of pixels
>> onto which I draw everything.
>> The other solution that has been suggested to me is to recompute
>> Waldo's position after adding each accessory.  This is annoying math,
>> however, and not always as easy as it seems.  What if I draw Waldo
>> holding a surfboard, at an angle, in his left hand?  The ends of the
>> surfboard might extend his bounding box a little bit (and a different
>> amount) in all four directions.  How do I recompute that belt buckle?
>> For some problems, we need a relative frame of reference.  I want a
>> pinhole, or something like it, so I can compose new images but keep
>> track of where I started.
>> I need to be able to answer, at all points: Where's Waldo?
>> --Carl
>> P.S. You may now all unleash your wrath upon me for the huge build-up
>> to the lame, telegraphed pun.
>> _________________________________________________
>>  For list-related administrative tasks:
>>  http://list.cs.brown.edu/mailman/listinfo/plt-dev

Posted on the dev mailing list.