<br><font size=2 face="Courier">Rob,</font>
<br>
<br><font size=2 face="Courier">I'm not sure a simple color map will do the trick. What you want is the</font>
<br><font size=2 face="Courier">Y channel of a 32 bit bitmap (i.e. RGB). Class JpegReadWriter implements a</font>
<br><font size=2 face="Courier">JPEG decoder that includes the necessary color space conversions, but from</font>
<br><font size=2 face="Courier">YCrCb to RGB. You need from RGB to YCrCb, so you'd have to implement the</font>
<br><font size=2 face="Courier">inverse of what is there already. Class JpegReadWriter2 at some point</font>
<br><font size=2 face="Courier">implements what you need, but all the heavy lifting is done by plugin</font>
<br><font size=2 face="Courier">primitives which are mostly in C.</font>
<br>
<br><font size=2 face="Courier">There are many colorspace standards (YUV, YIQ, YCrCb, HSV, etc..) and they</font>
<br><font size=2 face="Courier">can be subject to some interpretation. I've used the recommended RGB</font>
<br><font size=2 face="Courier">coefficients from CCIR 601-1, which is the relevant uncompressed digital</font>
<br><font size=2 face="Courier">video standard that applies to DVDs.</font>
<br>
<br><font size=2 face="Courier">I think the most straightforward way to get what you want is to implement</font>
<br><font size=2 face="Courier">a method to convert a 16 bit or 32 bit form to an 8 bit grayscale form -</font>
<br><font size=2 face="Courier">something like the example below. BTW, I have tested this method and it</font>
<br><font size=2 face="Courier">does work. It could certainly be optimized for performance as there are</font>
<br><font size=2 face="Courier">a lot of color objects created, but it should work with any source Form</font>
<br><font size=2 face="Courier">in Squeak.</font>
<br>
<br><font size=2 face="Courier">And here's some test code for the method given below:</font>
<br>
<br><font size=2 face="sans-serif"> | a b |</font>
<br><font size=2 face="sans-serif"> a _ Form fromDisplay: ((0 @ 0) extent: (400 @ 300)).</font>
<br><font size=2 face="sans-serif"> b _ a yComponent.</font>
<br><font size=2 face="sans-serif"> Display restoreAfter:</font>
<br><font size=2 face="sans-serif"> [</font>
<br><font size=2 face="sans-serif"> b displayScaledOn: Display</font>
<br><font size=2 face="sans-serif"> ].</font>
<br>
<br><font size=2 face="Courier">You can paste this in a workspace and DoIt.</font>
<br>
<br><font size=2 face="Courier"> -Dean Swan</font>
<br>
<br>
<br><font size=2 face="sans-serif">Form>><b>yComponent</b></font>
<br>
<br><font size=2 face="sans-serif"> "Returns an 8 bit form representing the Y component of self"</font>
<br>
<br><font size=2 face="sans-serif">| sourceHeight sourceWidth sourceDepth sourcePeeker sourcePixelValue sourcePixelColor</font>
<br><font size=2 face="sans-serif"> grayscaleForm grayscalePoker grayscaleDepth grayscalePixelColor yValue |</font>
<br>
<br><font size=2 face="sans-serif">sourceHeight _ self height.</font>
<br><font size=2 face="sans-serif">sourceWidth _ self width.</font>
<br><font size=2 face="sans-serif">sourceDepth _ self depth.</font>
<br>
<br><font size=2 face="sans-serif">grayscaleDepth _ 8.</font>
<br><font size=2 face="sans-serif">grayscaleForm _ Form extent: (sourceWidth @ sourceHeight) depth: grayscaleDepth.</font>
<br>
<br><font size=2 face="sans-serif">sourcePeeker _ BitBlt current bitPeekerFromForm: self.</font>
<br><font size=2 face="sans-serif">grayscalePoker _ BitBlt current bitPokerToForm: grayscaleForm.</font>
<br>
<br><font size=2 face="sans-serif">0 to: (sourceHeight - 1) do:</font>
<br><font size=2 face="sans-serif"> [ :y |</font>
<br><font size=2 face="sans-serif"> 0 to: (sourceWidth - 1) do:</font>
<br><font size=2 face="sans-serif"> [ :x |</font>
<br><font size=2 face="sans-serif"> sourcePixelValue _ sourcePeeker pixelAt: ( x @ y).</font>
<br><font size=2 face="sans-serif"> sourcePixelColor _ Color colorFromPixelValue: sourcePixelValue depth: sourceDepth.</font>
<br>
<br><font size=2 face="sans-serif"> yValue _ 0.299 * (sourcePixelColor red) + 0.587 * (sourcePixelColor green) + 0.114 * (sourcePixelColor blue).</font>
<br>
<br><font size=2 face="sans-serif"> grayscalePixelColor _ Color gray: yValue.</font>
<br>
<br><font size=2 face="sans-serif"> grayscalePoker pixelAt: (x @ y) put: (grayscaleForm pixelValueFor: grayscalePixelColor).</font>
<br><font size=2 face="sans-serif"> ]</font>
<br><font size=2 face="sans-serif"> ].</font>
<br>
<br><font size=2 face="sans-serif"> ^grayscaleForm.</font>
<br>
<br>
<br>
<br>
<br>
<table width=100%>
<tr valign=top>
<td>
<td><font size=1 face="sans-serif"><b>"Rob Hensley" <HensleyRj@Rockhurst.edu></b></font>
<br><font size=1 face="sans-serif">Sent by: squeak-dev-bounces@lists.squeakfoundation.org</font>
<p><font size=1 face="sans-serif">07/20/04 12:26 PM</font>
<br><font size=1 face="sans-serif">Please respond to The general-purpose Squeak developers list</font>
<br>
<td><font size=1 face="Arial"> </font>
<br><font size=1 face="sans-serif"> To: "The general-purpose Squeak developers list" <squeak-dev@lists.squeakfoundation.org></font>
<br><font size=1 face="sans-serif"> cc: </font>
<br><font size=1 face="sans-serif"> Subject: RE: Using video input in Squeak</font></table>
<br>
<br>
<br><font size=2 face="Courier New">Ultimately, what I want to do is a) convert the color image to B/W, b)<br>
set a threshold of what is "white" and what is "black" (that is,<br>
everything over a certain value -- let's say 123 -- will be considered<br>
white, and everything below will be considered black), and c) construct<br>
a Morph object out of the "black" part of the image. This Morph object<br>
will interact w/ the virtual balls (which are already done). <br>
<br>
-----Original Message-----<br>
From: squeak-dev-bounces@lists.squeakfoundation.org<br>
[mailto:squeak-dev-bounces@lists.squeakfoundation.org] On Behalf Of Bert<br>
Freudenberg<br>
Sent: Friday, July 16, 2004 6:31 PM<br>
To: The general-purpose Squeak developers list<br>
Subject: Re: Using video input in Squeak<br>
<br>
Use BitBlt with a colorMap (see BitBlt's class comment).<br>
<br>
- Bert -<br>
<br>
Am 16.07.2004 um 20:31 schrieb Rob Hensley:<br>
<br>
> I'm not sure who has been following my story, but I started this <br>
> project<br>
> using a Mac, and then switched to a PC running Windows (at the urging <br>
> of<br>
> my mentor).<br>
><br>
> I am using the DVideoShowDecoderPlugin. I have tested it, and it<br>
works.<br>
> My next step is separating the live actor's shadow part of the video<br>
> image from the white background: I need to convert the Form from color<br>
> to black and white. Once I have the shadow only, I can make a Morph<br>
out<br>
> of it and instruct the virtual balls to react to it.<br>
><br>
> Does anyone have any tips on the easiest way to convert the color<br>
image<br>
> to B/W?<br>
><br>
> -----Original Message-----<br>
> From: squeak-dev-bounces@lists.squeakfoundation.org<br>
> [mailto:squeak-dev-bounces@lists.squeakfoundation.org] On Behalf Of <br>
> Bert<br>
> Freudenberg<br>
> Sent: Wednesday, July 14, 2004 6:55 AM<br>
> To: The general-purpose Squeak developers list<br>
> Subject: Re: Using video input in Squeak<br>
><br>
> You would have to write a plugin similar to Diego's V4LPlugin that<br>
uses<br>
> Quicktime to read from the camera. To my knowledge, there is no such<br>
> plugin, yet. It might be a good idea to use the same primitives to<br>
> minimize platform-dependencies on the image side.<br>
><br>
> - Bert -<br>
><br>
> Am 12.07.2004 um 14:42 schrieb Rob Hensley:<br>
><br>
>> Ah, I'm using a Mac for this project...<br>
>><br>
>> Any ideas?<br>
>><br>
>> -----Original Message-----<br>
>> From: squeak-dev-bounces@lists.squeakfoundation.org on behalf of<br>
> Ned<br>
>> Konz<br>
>> Sent: Wed 7/7/2004 3:47 PM<br>
>> To: The general-purpose Squeak developers list<br>
>> Cc:<br>
>> Subject: Re: Using video input in Squeak<br>
>> <br>
>> <br>
>><br>
>> On Wednesday 07 July 2004 1:30 pm, Rob Hensley wrote:<br>
>> > That's exactly where I got the idea for the project!<br>
>> ><br>
>> > Do you have any suggestions as to where to start looking for<br>
>> interface<br>
>> > code/demos?<br>
>> <br>
>> Diego Gomez Deck has been working on an interface from<br>
> Video4Linux to<br>
>> Squeak.<br>
>> <br>
>> Look at:<br>
>> http://minnow.cc.gatech.edu/squeak/3765<br>
>> <br>
>> Also:<br>
>> http://minnow.cc.gatech.edu/squeak/1853<br>
>> http://minnow.cc.gatech.edu/squeak/2411</font>
<br><font size=2 face="Courier New">>> http://www.is.titech.ac.jp/~ohshima/squeak/DShowVideo/<br>
>> <br>
>> --<br>
>> Ned Konz<br>
>> http://bike-nomad.com/squeak/<br>
<br>
<br>
<br>
</font>
<br>
<br>