Pets, Plants, and Computer Vision
Header

Simple Steganography

February 16th, 2013 | Posted by admin in code | computer vision | demo | Fun! | pics or it didn't happen | steganography - (Comments Off on Simple Steganography)

I had a moment to play with steganography while I was watching tv tonight. Steganography is a way of encoding text messages inside image files in such a way that they don’t alter the original image content. I came across this nice little tutorial using the stepic python library. I was able to get Stepic working with and hooked into SimpleCV with only a little bit of massaging (needed to turn SimpleCV Image to a PIL Image and back again). Here is the actual commit.

The Source Image

The Source Image

 

 

The encoded Image.

This dinosaur has an encoded message, can you find it?.

I wrote a little bit of code to test my work and to see if I could tease out the algorithm. Basically all I did was encode a message, in this case the wikipedia entry on stegosaurs, into an image and then subtracted that image from the original imaage to create a diff. To the naked eye both the source image and the encoded image look the same. The diff also looks as it should, that is to say all black. To dig a bit deeper I applied a histogram equalization function to stretch out the images’s dynamic range. Bingo, the encoding scheme is clearly visible.

The pixelwise difference between the source and encoded image.

The pixelwise difference between the source and encoded image.

The difference between the source and encode information using an equalize operation.

The difference between the source and encode information using an equalize operation.

The next step is to look at the individual color channels to see if they are holding on to any information. I could look at the actual algorithm in the source, but that would be no fun. It would be interesting to see if I could build a heuristic for determining which images have encoded data. I would also be useful to add AES encryption to the encode/decode calls in SimpleCV.

As a side note I tried to decode my image using this on-line utility but I had no luck. My guess is there are incompatibilities between the stable 0.3 release of the stepic library and the development 0.4 release that might be on the utility.

FIRST 2013 Robot Ideas

January 6th, 2013 | Posted by admin in Ann Arbor | automation | FIRST | Fun! | Ideas | Inspiration | Maker Works | robots - (Comments Off on FIRST 2013 Robot Ideas)

I am helping mentor with FIRST Robotics Team 830 this year. Here are the rules for the  2013 FIRST Robotics Competition.  The TL;DR is that the robot basically needs to collect and shoot frisbees and climbing a really tall tower. The video below describes things very succinctly.

 

 

We need to get this done in the mater of just a few weeks. I started looking for a few inspiration ideas.

 

A personal favorite, the RiSE robot from the KodLab. A little too complex for our timeframe.

 

 

I really like this mechanism but I am not sure it will work on the pyramid.

 

 

Here is a slightly simpler version of the same mechanism.

 

 

This is a similar approach. Not quite applicable to our situation.

 

 

Here is a FIRST team actually meeting the challenge.

 

 

This design looks like it could be used for our applications with some modifications.

 

 

On the subject the frisbee launching this mechanism rules.

Finally, a nice primer on the physics of frisbee launching.

 

Perler Bead Project

July 2nd, 2012 | Posted by admin in code | computer vision | domestic life | Fun! | Uncategorized - (Comments Off on Perler Bead Project)

So I had to run to Jo-Ann fabric for a few odds and ends. My Mom gave me a couple of 50% off coupons and on a whim I purchased some perler beads and a tray for about $10. Perler beads are this kids craft where you patiently place little plastic beads on tray and then fuse them using an iron to create various toys. I am pretty sure that the beads themselves are just a ruse by the vacuum cleaner companies to sell more powerful vacuums.

Perler Beads

Perler Bead Set

I wanted to see if I could use SimpleCV to map images to  pearler bead colors to create little coasters from my photos. I took the beads and created a square calibration grid so I could pull out the colors. I then quantized the image to a palette and saved the results.

This is what the calibration grid looks like when I quantize it to have 16 colors (note that this result is not repeatable because of the k-means calculation’s initial conditions).

To test my approach I used an input image (in this case Lena), pixelized the image to match the perler bead grid, and then re-applied the quantization to the pixelized image. The results are not that great.

Image pipeline, input, pixelized image (17×17 block size), and quantized result.

There are about five colors in the output image and it seems to lose a lot of its information. I did some digging and found that two things seem to be going on. First, the quantization step seems to have some bad initial conditions. This is to say that I take the image and try to cluster the colors in it into 16 groups using k-means. If the algorithm starts with a bad initial condition a lot of the clusters “run into one another” and I end up with less than 16 color groups. The other problem is subtler and has to do with image dithering. I anticipated that this might be a problem because gif images also use a quantized color palette (for gifs it is 256 colors) to compress the image size. Back in the old days of the web you would use a technique called dithering as part of your gif compression algorithms to make photographs look more realistic. Generally dithering is used to lessen the effect of quantization error around gradients. To illustrate this I found an image on wikipedia with a lot of colors and color gradients, here is what would come out of the naive SimpleCV quantization (top is input, bottom is output using img.palettize(bins=256)):

Quantization makes things look weird. The top is the input image and the bottom is the image quantized to only have 256 colors (just like a normal GIF image).

Now here is the same result using ImageMagick with GIF dithering turned on (specifically the command: convert test.jpg -dither Riemersma -colors 256 test.gif).

Still 256 colors, but the dithering makes the gradients around the lights less apparent.

As you can see the dithered images look way better. The effect seems to hold even when I shrink the number of colors down to 16 but still use dithering. In the two images below the top is the output from SimpleCV quantizing to 16 colors, while the bottom is ImageMagick result with added dithering (note that there may be some re-compression artifacts from when I saved the image).

Top is SimpleCV’s output when I quantize the image to have 16 colors, while the bottom image is ImageMagicks results with 16 colors and dithering.

Hopefully in the next week or two I can read up on dithering algorithms and see if I can’t add a few to SimpleCV.

Praying Mantis Habitat

June 15th, 2012 | Posted by admin in Ann Arbor | cute | domestic life | Fun! | mantis | Michigan | Uncategorized - (Comments Off on Praying Mantis Habitat)

Today I caught a juvenile praying mantis in the bushes outside the office. There are only two species in Michigan it looks to be the more common Chinese Praying Mantis. I had to stop at the pet store today on my way home to get some supplies for the rats so I picked up a few things to make a mantid habitat. All told I think I spent about $15. I have done a fair bit of insect rearing in the past and it really isn’t all that hard. My first job as an undergrad was to tend a colony of giant Madagascar Hissing Cockroaches at a research lab at the University of Michigan. Keeping a colony of insects running is about as difficult as keeping a couple house plants alive, if not easier. You basically need to provide food, water, and shelter, and sometimes muck with the climate. Since praying mantis live wild in Michigan you don’t really need to make a lot of climate considerations other than not placing the animal’s cage in direct sun light.

 

image

Supplies (terrarium, gravel, sponge/cup, leaves/twigs, and crickets)

To create the habitat I got a $10 two-gallon plastic terrarium at the pet store. I also picked up a small bag of gravel for about $2.50 and a dozen small crickets for a buck. To create a  habitat I rinsed out the terrarium and place some gravel on the bottom. I then added some sticks and fresh twigs I found in the yard. Praying mantises like to hunt while perched in grass and brush so it is important to provide some vertical features in the terrarium. For water I took an old plastic container (like a yogurt cup), cut it down to about an inch high, and then cut a clean sponge to fit the cup. The mantis and its pray can drink up water from the sponge without the water spilling everywhere. Once the cup is filled the sponge should stay wet for at least a few days at a stretch. Praying Mantises will only eat live food, so I picked up a half dozen small crickets, but I fear they may be too large for such a tiny mantis. To supplement that mantis’s diet I am going to add a moldy piece of fruit that has fruit flies to the terrarium. The hope is that the mantis will eat the fruit flies until it reaches a suitable size to capture the crickets. To capture the fruit files I put half an apple out by my dumpster over night. The apple should provide food for the fruit flies and the crickets for at least two weeks.

The finished product

The finished mantis habitat.